mbe: compile rule RHS into a pre-flattened transcription template [clap_derive -0.5%, tt-muncher -1.8%] - #83
Open
xmakro wants to merge 1 commit into
Open
Conversation
Transcription walked the RHS tree token by token on every expansion: one dispatch, span mark, and buffer push per literal token, plus a metavar normalization per occurrence. The tree is now lowered once per rule (lazily, on first expansion) into a template whose runs of literal tokens, including whole literal delimited groups, are pre-encoded as flat entries. Transcription copies each run into the output buffer, rebases depths and match indices, and marks the copied spans in place. Metavar occurrences carry their normalization precomputed, and the sequence lockstep check walks a precollected list of the metavars in the sequence subtree instead of re-walking the tree. clap_derive check -0.52%, html5ever check -0.46%, syn check -0.27%, tt-muncher check -1.81%, no regressions.
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.
Follow-up to #57, stacked on #82. Transcription walked the RHS tree token by token on every expansion of a rule: one dispatch, one span mark, and one buffer push per literal token, plus a metavar normalization per occurrence and a full tree re-walk for every sequence lockstep check.
This lowers each rule RHS once (lazily, on first expansion) into a compiled template:
MacroRulesNormalizedIdentprecomputed.OnceLock).Diagnostics are preserved: the sequence segments keep the spans and metavar ident lists the lockstep and no-repeatable-vars errors need, and the close-bracket spacing hack (rust-lang#114571) is replicated in the pre-encoded runs.
Performance (ThinLTO stage2, jemalloc, instructions:u, full scenario, measured on top of the perf stack; A/B over 10 crates x Check/Debug, base includes #82):
Correctness: stage2 build green;
x check compilergreen on this branch standalone; full tests/ui run has a failure set byte-identical to the pre-existing baseline (21301 passed, zero new diffs).