Skip to content

Regeneralize the "-1 for None" change - #160376

Draft
scottmcm wants to merge 1 commit into
rust-lang:mainfrom
scottmcm:more-minus-one-again
Draft

Regeneralize the "-1 for None" change#160376
scottmcm wants to merge 1 commit into
rust-lang:mainfrom
scottmcm:more-minus-one-again

Conversation

@scottmcm

@scottmcm scottmcm commented Aug 2, 2026

Copy link
Copy Markdown
Member

Not planning on un-drafting this until after #158734 lands.

The "prefer the smaller magnitude" change (#155473) had been applied pretty narrowly: just to option-like niches and just to non-bool-like values. But now that llvm/llvm-project#208611 has been fixed, let's apply it more generally.

In doing so I ended up pretty substantially restructuring the function. I also greatly expanded the comments and added unit tests for it so it's easier to exercise all the paths (and much quicker than rebuilding all of rustc). I made sure to keep the previous "try to keep zero available for None" cleverness, however.


Or, if you prefer, this is contradicting the old comment in the code that

If niche zero is already reserved, the selection of bounds are of little interest.

🙂

@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 Aug 2, 2026
@rust-log-analyzer

This comment has been minimized.

@scottmcm
scottmcm force-pushed the more-minus-one-again branch from 71d4b14 to c568872 Compare August 2, 2026 09:04
@rust-log-analyzer

This comment has been minimized.

@scottmcm

This comment was marked as outdated.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 2, 2026
Regeneralize the "-1 for None" change


try-job: aarch64*llvm-21*
@rust-bors

This comment was marked as outdated.

@scottmcm
scottmcm force-pushed the more-minus-one-again branch from c568872 to 7ca10fc Compare August 2, 2026 16:20
@rust-log-analyzer

This comment has been minimized.

@scottmcm

scottmcm commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

:/

sccache: error: Timed out waiting for server startup. Maybe the remote service is unreachable?

@scottmcm scottmcm closed this Aug 2, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 2, 2026
@scottmcm scottmcm reopened this Aug 2, 2026
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 2, 2026
@rust-log-analyzer

This comment has been minimized.

@scottmcm
scottmcm force-pushed the more-minus-one-again branch from 7ca10fc to 0e8bca9 Compare August 2, 2026 16:34
@rust-log-analyzer

This comment has been minimized.

@scottmcm

scottmcm commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

@bors try jobs=aarch64llvm-21

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 2, 2026
Regeneralize the "-1 for None" change


try-job: aarch64*llvm-21*
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 84c2f57 failed: CI. Failed jobs:

@scottmcm

scottmcm commented Aug 5, 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 Aug 5, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 5, 2026
Regeneralize the "-1 for None" change
@rust-bors

rust-bors Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 99c49b3 (99c49b36c0e329e5984e2b569f71439d947c60e2)
Base parent: 87212ce (87212cef77e7bfa92ba0c4850be1d089745ba6fc)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (99c49b3): 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.3% [0.3%, 0.3%] 1
Regressions ❌
(secondary)
1.3% [0.3%, 2.4%] 25
Improvements ✅
(primary)
-0.2% [-0.3%, -0.2%] 12
Improvements ✅
(secondary)
-0.7% [-2.8%, -0.2%] 20
All ❌✅ (primary) -0.2% [-0.3%, 0.3%] 13

Max RSS (memory usage)

Results (primary 3.9%, secondary 26.9%)

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

mean range count
Regressions ❌
(primary)
3.9% [3.9%, 3.9%] 1
Regressions ❌
(secondary)
26.9% [23.4%, 30.5%] 12
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.9% [3.9%, 3.9%] 1

Cycles

Results (primary -3.0%, secondary 16.7%)

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)
19.8% [7.4%, 31.8%] 12
Improvements ✅
(primary)
-3.0% [-3.0%, -3.0%] 1
Improvements ✅
(secondary)
-2.3% [-2.5%, -2.0%] 2
All ❌✅ (primary) -3.0% [-3.0%, -3.0%] 1

Binary size

Results (primary -0.1%, 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.0% [0.0%, 0.0%] 3
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 11
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 13
Improvements ✅
(secondary)
-0.8% [-0.8%, -0.8%] 1
All ❌✅ (primary) -0.1% [-0.1%, 0.0%] 16

Bootstrap: 456.607s -> 458.361s (0.38%)
Artifact size: 399.19 MiB -> 399.08 MiB (-0.03%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 5, 2026
@scottmcm
scottmcm force-pushed the more-minus-one-again branch from 0e8bca9 to 5cb4249 Compare August 6, 2026 16:09
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