Skip to content

[perf] Use a flat token stream representation when lexing - #159378

Draft
Kobzol wants to merge 1 commit into
rust-lang:mainfrom
Kobzol:lexer-flat
Draft

[perf] Use a flat token stream representation when lexing#159378
Kobzol wants to merge 1 commit into
rust-lang:mainfrom
Kobzol:lexer-flat

Conversation

@Kobzol

@Kobzol Kobzol commented Jul 16, 2026

Copy link
Copy Markdown
Member

Opening for a perf experiment, nothing to see here.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 16, 2026
@Kobzol

Kobzol commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

@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 Jul 16, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 16, 2026
[perf] Use a flat token stream representation when lexing
@rust-bors

rust-bors Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 8374c7c (8374c7ca6b40db24e90f1c62568ddd867a1d48ce)
Base parent: ab4bbeb (ab4bbeb07dc7dc2d30e9f83d3e0326df981e0ee2)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (8374c7c): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@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.4% [0.1%, 1.2%] 73
Regressions ❌
(secondary)
0.6% [0.1%, 1.4%] 59
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.8% [-2.4%, -1.3%] 13
All ❌✅ (primary) 0.4% [0.1%, 1.2%] 73

Max RSS (memory usage)

Results (secondary -6.6%)

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)
3.9% [1.8%, 8.5%] 14
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-13.6% [-22.8%, -2.3%] 21
All ❌✅ (primary) - - 0

Cycles

Results (primary 1.1%, secondary -7.3%)

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

mean range count
Regressions ❌
(primary)
2.6% [2.4%, 3.0%] 3
Regressions ❌
(secondary)
3.5% [2.1%, 5.2%] 8
Improvements ✅
(primary)
-3.4% [-3.4%, -3.4%] 1
Improvements ✅
(secondary)
-13.6% [-19.9%, -4.9%] 14
All ❌✅ (primary) 1.1% [-3.4%, 3.0%] 4

Binary size

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

Bootstrap: 489.393s -> 489.02s (-0.08%)
Artifact size: 389.94 MiB -> 389.88 MiB (-0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 16, 2026
@Kobzol

Kobzol commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

Seems like doing the flat representation in the lexer doesn't help much when we still have to convert it back to all the allocations required for the parser. The whole thing would have to be flattened to have the desired perf. effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

3 participants