Skip to content

Minor optimizations around macro parsing - #164540

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
bal-e:mini-macro-opts
Oct 21, 2026
Merged

rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
bal-e:mini-macro-opts

Conversation

@bal-e

@bal-e bal-e commented Oct 18, 2026 •

Copy link
Copy Markdown

Picked out some standalone commits from my macro matching optimization work. These are independent small optimizations that should add up to a tiny but measurable perf win.

Part of #159951. Best reviewed commit-by-commit. No LLMs used.

r? @nnethercote

arya dradjica added 3 commits October 18, 2026 23:04
It does not have any use, and it is a no-op we have to process on the
hot path of macro parsing.
The parsing code is much hotter than `compute_locs()`, so perform the
match over there. This might mildly change the debug representation of
computed `[MatcherLoc]`s, but it's probably worthwhile for perf.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 18, 2026
@rustbot

rustbot commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @nnethercote (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

@nnethercote

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 19, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 19, 2026
Minor optimizations around macro parsing
@rust-bors

rust-bors Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 9d5633d (9d5633d7dfe2a53ced47ac7b1c2ea122fe6ca791)
Base parent: b6eeb93 (b6eeb93c992027a03e1fd120b6652546396b142c)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (9d5633d): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.2%] 2
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 1.5%, secondary 1.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.5% [1.5%, 1.5%] 1
Regressions ❌
(secondary)
1.2% [1.2%, 1.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.5% [1.5%, 1.5%] 1

Cycles

Results (secondary 2.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [2.4%, 2.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 489.811s -> 492.784s (0.61%)
Artifact size: 408.98 MiB -> 409.03 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 19, 2026
@nnethercote

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5fc2428 has been approved by nnethercote

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

Reason for tree closure: spurious failures

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 20, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 20, 2026
Minor optimizations around macro parsing

Picked out some standalone commits from my macro matching optimization work. These are independent small optimizations that should add up to a tiny but measurable perf win.

Part of rust-lang#159951. Best reviewed commit-by-commit. No LLMs used.

r? @nnethercote
rust-bors Bot pushed a commit that referenced this pull request Oct 20, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163338 (MIR move elimination [4/6]: MoveElimination)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164540 (Minor optimizations around macro parsing)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164595 (Allow attributes in function trait parameters)
 - #164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 20, 2026
Minor optimizations around macro parsing

Picked out some standalone commits from my macro matching optimization work. These are independent small optimizations that should add up to a tiny but measurable perf win.

Part of rust-lang#159951. Best reviewed commit-by-commit. No LLMs used.

r? @nnethercote
rust-bors Bot pushed a commit that referenced this pull request Oct 20, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164540 (Minor optimizations around macro parsing)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164595 (Allow attributes in function trait parameters)
 - #164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
rust-bors Bot pushed a commit that referenced this pull request Oct 20, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164540 (Minor optimizations around macro parsing)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164595 (Allow attributes in function trait parameters)
 - #164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 20, 2026
Minor optimizations around macro parsing

Picked out some standalone commits from my macro matching optimization work. These are independent small optimizations that should add up to a tiny but measurable perf win.

Part of rust-lang#159951. Best reviewed commit-by-commit. No LLMs used.

r? @nnethercote
rust-bors Bot pushed a commit that referenced this pull request Oct 20, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163668 (Remap syntax contexts and expansion ids for det. metadata encoding)
 - #160404 (fd-views: AsRef<File>&Co. for BorrowedFd)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163317 (Stop useless caching of post-LTO artifact caching for fat LTO)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164507 (Encode HashMap and HashSet in deterministic order when an encoder requires determinism)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164540 (Minor optimizations around macro parsing)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164595 (Allow attributes in function trait parameters)
 - #164641 (Stabilize `slice_split_once`)
 - #164646 (Adjust rustfmt subtree sync docs to not use `--allow-noop` for now)
rust-bors Bot pushed a commit that referenced this pull request Oct 21, 2026
Rollup of 20 pull requests

Successful merges:

 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163668 (Remap syntax contexts and expansion ids for det. metadata encoding)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163317 (Stop useless caching of post-LTO artifact caching for fat LTO)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164507 (Encode HashMap and HashSet in deterministic order when an encoder requires determinism)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164540 (Minor optimizations around macro parsing)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164595 (Allow attributes in function trait parameters)
 - #164616 (Add test for VecDeque with a custom allocator)
 - #164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
 - #164641 (Stabilize `slice_split_once`)
 - #164646 (Adjust rustfmt subtree sync docs to not use `--allow-noop` for now)
@rust-bors
rust-bors Bot merged commit 2013a33 into rust-lang:main Oct 21, 2026
15 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 21, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 21, 2026
Rollup merge of #164540 - bal-e:mini-macro-opts, r=nnethercote

Minor optimizations around macro parsing

Picked out some standalone commits from my macro matching optimization work. These are independent small optimizations that should add up to a tiny but measurable perf win.

Part of #159951. Best reviewed commit-by-commit. No LLMs used.

r? @nnethercote
github-actions Bot pushed a commit to rust-lang/stdarch that referenced this pull request Oct 22, 2026
Rollup of 20 pull requests

Successful merges:

 - rust-lang/rust#163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - rust-lang/rust#163668 (Remap syntax contexts and expansion ids for det. metadata encoding)
 - rust-lang/rust#163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - rust-lang/rust#163317 (Stop useless caching of post-LTO artifact caching for fat LTO)
 - rust-lang/rust#163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - rust-lang/rust#164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - rust-lang/rust#164507 (Encode HashMap and HashSet in deterministic order when an encoder requires determinism)
 - rust-lang/rust#164611 (Improve bit permutation codegen)
 - rust-lang/rust#164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - rust-lang/rust#148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - rust-lang/rust#162668 (document that `!` does bitwise and logical negation)
 - rust-lang/rust#164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - rust-lang/rust#164509 (layout invariant: turn delayed bug back into proper assertion)
 - rust-lang/rust#164540 (Minor optimizations around macro parsing)
 - rust-lang/rust#164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - rust-lang/rust#164595 (Allow attributes in function trait parameters)
 - rust-lang/rust#164616 (Add test for VecDeque with a custom allocator)
 - rust-lang/rust#164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
 - rust-lang/rust#164641 (Stabilize `slice_split_once`)
 - rust-lang/rust#164646 (Adjust rustfmt subtree sync docs to not use `--allow-noop` for now)
jieyouxu pushed a commit to jieyouxu/rustfmt that referenced this pull request Oct 22, 2026
Rollup of 20 pull requests

Successful merges:

 - rust-lang/rust#163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - rust-lang/rust#163668 (Remap syntax contexts and expansion ids for det. metadata encoding)
 - rust-lang/rust#163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - rust-lang/rust#163317 (Stop useless caching of post-LTO artifact caching for fat LTO)
 - rust-lang/rust#163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - rust-lang/rust#164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - rust-lang/rust#164507 (Encode HashMap and HashSet in deterministic order when an encoder requires determinism)
 - rust-lang/rust#164611 (Improve bit permutation codegen)
 - rust-lang/rust#164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - rust-lang/rust#148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - rust-lang/rust#162668 (document that `!` does bitwise and logical negation)
 - rust-lang/rust#164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - rust-lang/rust#164509 (layout invariant: turn delayed bug back into proper assertion)
 - rust-lang/rust#164540 (Minor optimizations around macro parsing)
 - rust-lang/rust#164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - rust-lang/rust#164595 (Allow attributes in function trait parameters)
 - rust-lang/rust#164616 (Add test for VecDeque with a custom allocator)
 - rust-lang/rust#164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
 - rust-lang/rust#164641 (Stabilize `slice_split_once`)
 - rust-lang/rust#164646 (Adjust rustfmt subtree sync docs to not use `--allow-noop` for now)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants