perf: skip nonstandard_macro_braces work when the lint is disabled - #3
Closed
xmakro wants to merge 1 commit into
Closed
perf: skip nonstandard_macro_braces work when the lint is disabled#3xmakro wants to merge 1 commit into
xmakro wants to merge 1 commit into
Conversation
…sabled `NONSTANDARD_MACRO_BRACES` is a nursery (allow-by-default) lint, but `is_offending_macro` ran on every item/stmt/expr/ty unconditionally: walking the full macro backtrace (`outer_expn_data` clone + hygiene thread-local re-entry) and hashing macro names against the brace map, even though nothing could be emitted when the lint is disabled. Bail out early on two cheap checks. First, if the span isn't from a macro there is nothing to do (same as the original loop, but before any lint-level lookup so the common non-macro node stays free). Then, once we know the span came from a macro, skip everything when the lint is allowed at this node. Behaviour is unchanged when the lint is enabled. Same-binary A/B (instructions, N=12 medians) on macro-heavy code shows wasmi -8.3%; macro-light crates (tokio/syn/regex/ripgrep/serde) stay within noise. Diagnostics are byte-identical and the UI test is green.
xmakro
force-pushed
the
perf/nonstandard-macro-braces-guard
branch
from
June 1, 2026 04:00
695b6c1 to
f4e0c41
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NONSTANDARD_MACRO_BRACESis a nursery (allow-by-default) lint, butis_offending_macroran on every item, stmt, expr and ty regardless of whether the lint was enabled. For each node it walked the full macro backtrace (which clonesExpnDataand re-enters the hygiene thread-local once per level) and hashed macro names against the brace map. When the lint is disabled none of that can produce a warning, so it is all wasted.The fix adds two early returns at the top of
is_offending_macro:When the lint is enabled the second guard is never taken, so behaviour is unchanged.
Benchmarked performance, same-binary A/B with
perf stat, N=12 medians. Two drivers built against identical libs, differing only in this change:The improvement is on macro-heavy code, the rest are within noise