Skip to content

[experiment] Try to make index vec smaller when possible - #157799

Draft
panstromek wants to merge 27 commits into
rust-lang:mainfrom
panstromek:try-to-make-index-vec-smaller
Draft

[experiment] Try to make index vec smaller when possible#157799
panstromek wants to merge 27 commits into
rust-lang:mainfrom
panstromek:try-to-make-index-vec-smaller

Conversation

@panstromek

@panstromek panstromek commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

View all comments

This is very ugly and unsound, but I want to check CI and perf to see whether there's at least something to gain.

Notes

  • this roundtrips every mutation through vec, which might mask any gains if it's not optimized out properly. I hope I'm gonna see at least some change to see whether it's worth cleaning up.

TODO

  • not sure about Dyn[Send|Sync]
  • Why I had to change the lifetimes in ProjectedMaybeOwner? (Failed in borrowck in rustc_middle)
  • proper desc
  • proper commits

@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 Jun 12, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@panstromek

This comment was marked as outdated.

@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 Jun 12, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 12, 2026
…try>

[experiment] Try to make index vec smaller when possible
@rust-bors

rust-bors Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 76803df (76803df0625aa385701a24c186e4526355371fd5, parent: a1e52fc1cf67929a7c01ed9c037520e276ec98fd)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (76803df): 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
@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.2%, 0.7%] 155
Regressions ❌
(secondary)
0.4% [0.1%, 1.0%] 107
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.5% [-0.9%, -0.4%] 7
All ❌✅ (primary) 0.4% [0.2%, 0.7%] 155

Max RSS (memory usage)

Results (primary -0.9%, 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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.9% [-1.0%, -0.8%] 4
Improvements ✅
(secondary)
-1.2% [-2.0%, -0.3%] 2
All ❌✅ (primary) -0.9% [-1.0%, -0.8%] 4

Cycles

Results (primary 2.2%)

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

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

Binary size

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

Bootstrap: 519.113s -> 519.594s (0.09%)
Artifact size: 400.82 MiB -> 400.82 MiB (-0.00%)

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

This comment was marked as resolved.

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 14, 2026
rust-bors Bot pushed a commit that referenced this pull request Jun 14, 2026
…try>

[experiment] Try to make index vec smaller when possible
@rust-bors

rust-bors Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: e8c5fee (e8c5feedca5bbedf67ca37e9d86d33007371e1f6, parent: 1f087276ba7a16d74ec04739ecf582ae495b3b79)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (e8c5fee): 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
@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.2%, 0.7%] 162
Regressions ❌
(secondary)
0.4% [0.2%, 0.8%] 118
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.5% [-0.9%, -0.4%] 7
All ❌✅ (primary) 0.4% [0.2%, 0.7%] 162

Max RSS (memory usage)

Results (primary -0.9%, secondary -1.9%)

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)
- - 0
Improvements ✅
(primary)
-0.9% [-1.7%, -0.5%] 8
Improvements ✅
(secondary)
-1.9% [-2.0%, -1.8%] 5
All ❌✅ (primary) -0.9% [-1.7%, -0.5%] 8

Cycles

Results (secondary 3.0%)

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.0% [2.2%, 4.1%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 526.872s -> 519.342s (-1.43%)
Artifact size: 401.48 MiB -> 400.98 MiB (-0.12%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 14, 2026
@panstromek

Copy link
Copy Markdown
Contributor 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 Jun 15, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 15, 2026
…try>

[experiment] Try to make index vec smaller when possible
@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 6, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 6, 2026
…try>

[experiment] Try to make index vec smaller when possible
@rust-bors

rust-bors Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 24ab8cd (24ab8cdecc3537bcc3f193657d78abe20d3cd650)
Base parent: 3659db0 (3659db0d3e2cd634c766fcda79ed118eca31a9fd)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (24ab8cd): 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
@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.3% [0.2%, 0.4%] 85
Regressions ❌
(secondary)
0.4% [0.2%, 0.9%] 35
Improvements ✅
(primary)
-0.2% [-0.3%, -0.1%] 4
Improvements ✅
(secondary)
-0.3% [-0.9%, -0.1%] 29
All ❌✅ (primary) 0.3% [-0.3%, 0.4%] 89

Max RSS (memory usage)

Results (primary -1.0%, secondary 0.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)
5.0% [1.5%, 8.5%] 2
Improvements ✅
(primary)
-1.0% [-1.4%, -0.7%] 4
Improvements ✅
(secondary)
-2.6% [-3.0%, -2.2%] 3
All ❌✅ (primary) -1.0% [-1.4%, -0.7%] 4

Cycles

Results (secondary 4.1%)

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)
4.1% [4.1%, 4.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.0%, secondary -0.0%)

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)
- - 0
Improvements ✅
(primary)
-0.0% [-0.1%, -0.0%] 31
Improvements ✅
(secondary)
-0.0% [-0.1%, -0.0%] 5
All ❌✅ (primary) -0.0% [-0.1%, -0.0%] 31

Bootstrap: 491.532s -> 488.059s (-0.71%)
Artifact size: 388.93 MiB -> 388.51 MiB (-0.11%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 6, 2026
…revious green

This lookup is the most common operation in try_mark_green
@panstromek
panstromek force-pushed the try-to-make-index-vec-smaller branch from 04e68ab to c89fc82 Compare July 6, 2026 20:12
@panstromek

Copy link
Copy Markdown
Contributor 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 6, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 6, 2026
…try>

[experiment] Try to make index vec smaller when possible
@rust-bors

rust-bors Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 07d35df (07d35df71cb619d79cefd6d19713307996292218)
Base parent: 36714a9 (36714a9983d6ba11203d8bb87a1b372247fbcf06)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (07d35df): 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
@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.2%, 0.7%] 96
Regressions ❌
(secondary)
0.4% [0.2%, 0.9%] 42
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 2
Improvements ✅
(secondary)
-0.3% [-0.8%, -0.1%] 24
All ❌✅ (primary) 0.4% [-0.2%, 0.7%] 98

Max RSS (memory usage)

Results (primary -1.0%, secondary -3.9%)

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)
- - 0
Improvements ✅
(primary)
-1.0% [-1.2%, -0.6%] 4
Improvements ✅
(secondary)
-3.9% [-8.0%, -1.6%] 6
All ❌✅ (primary) -1.0% [-1.2%, -0.6%] 4

Cycles

Results (secondary -11.3%)

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.5% [3.5%, 3.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-18.6% [-34.2%, -3.1%] 2
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 489.375s -> 488.234s (-0.23%)
Artifact size: 388.97 MiB -> 389.03 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 6, 2026
@panstromek

panstromek commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

It seems like no matter what I do in try_mark_previous_green, the result is slower, which is pretty weird given that the changes are usually just extracting as_slice call out of a hot loop. Let's try to get back and re-measure the most positive result so far (the exec_cache_promotions change), maybe something got changed on main and changes the baseline measurement.

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 7, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 7, 2026
…try>

[experiment] Try to make index vec smaller when possible
@rust-bors

rust-bors Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: c7db7b7 (c7db7b71ea016e508e29d99a6f84aff65f37a5f4)
Base parent: b960fcf (b960fcf2ff0f04967b30b947be8fc155fb067901)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (c7db7b7): 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
@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.2% [0.2%, 0.3%] 23
Regressions ❌
(secondary)
0.2% [0.1%, 0.4%] 13
Improvements ✅
(primary)
-0.2% [-0.3%, -0.1%] 5
Improvements ✅
(secondary)
-0.3% [-0.9%, -0.1%] 37
All ❌✅ (primary) 0.1% [-0.3%, 0.3%] 28

Max RSS (memory usage)

Results (primary 0.5%, secondary -2.2%)

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

mean range count
Regressions ❌
(primary)
4.0% [2.1%, 5.9%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.3% [-1.9%, -0.6%] 4
Improvements ✅
(secondary)
-2.2% [-2.6%, -1.7%] 5
All ❌✅ (primary) 0.5% [-1.9%, 5.9%] 6

Cycles

Results (primary -2.3%, secondary 0.2%)

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.8% [3.8%, 3.8%] 1
Improvements ✅
(primary)
-2.3% [-2.3%, -2.3%] 1
Improvements ✅
(secondary)
-3.4% [-3.4%, -3.4%] 1
All ❌✅ (primary) -2.3% [-2.3%, -2.3%] 1

Binary size

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

Bootstrap: 489.183s -> 493.103s (0.80%)
Artifact size: 388.47 MiB -> 388.61 MiB (0.04%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 7, 2026
@rust-bors

rust-bors Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #158059) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

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.

4 participants