Skip to content

Optimize: skip logging and stats collection calls if they are no-ops#20839

Merged
JukkaL merged 4 commits intomasterfrom
optimize-build
Feb 17, 2026
Merged

Optimize: skip logging and stats collection calls if they are no-ops#20839
JukkaL merged 4 commits intomasterfrom
optimize-build

Conversation

@JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Feb 17, 2026

We had lots of logging that was fairly expensive even if disabled, since
just calling the functions or constructing the log messages adds overhead,
and calling time.time() to collect timings has a cost. Now put some of the
most expensive logging/stats calls behind fast bool flag checks.

Based on CPU profiles, this should improve performance of mostly cached
incremental runs if they are big enough by at least 2%, but potentially by
even more (hard to predict).

We had lots of logging that was fairly expensive even if disabled, since
just calling the functions or constructing the log messages was slow.
Now put some of the most expensive logging calls behind fast bool flag
checks.
@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@JukkaL JukkaL merged commit 00b5064 into master Feb 17, 2026
24 checks passed
@JukkaL JukkaL deleted the optimize-build branch February 17, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants