Skip to content

Conversation

@oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Nov 5, 2025

part of #136006

This PR only changes the internal representation of NonZero, NonMax, ... and other integral range types in libcore. This subsequently affects other types made up of it, but nothing really changes except that the field of NonZero is now accessible safely in contrast to the rustc_layout_scalar_range_start attribute, which has all kinds of obscure rules on how to properly access its field.

@rustbot
Copy link
Collaborator

rustbot commented Nov 5, 2025

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 5, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 5, 2025

r? @scottmcm

rustbot has assigned @scottmcm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@oli-obk oli-obk changed the title Start using pattern types in libcore [perf] Start using pattern types in libcore Nov 5, 2025
@oli-obk
Copy link
Contributor Author

oli-obk commented Nov 5, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Nov 5, 2025
[perf] Start using pattern types in libcore
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 5, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Nov 5, 2025

☀️ Try build successful (CI)
Build commit: 0ff9d47 (0ff9d47ff7e1b381184bd9c0734a1b9001b2b6f1, parent: 1ef7943ee607160a564655b6596f83670ef95df5)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0ff9d47): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@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)
1.8% [0.2%, 5.7%] 14
Regressions ❌
(secondary)
2.8% [0.2%, 5.5%] 4
Improvements ✅
(primary)
-0.5% [-0.5%, -0.5%] 1
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 2
All ❌✅ (primary) 1.7% [-0.5%, 5.7%] 15

Max RSS (memory usage)

Results (primary -0.8%, secondary 2.9%)

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

mean range count
Regressions ❌
(primary)
2.8% [2.8%, 2.8%] 1
Regressions ❌
(secondary)
3.8% [1.7%, 6.7%] 12
Improvements ✅
(primary)
-2.0% [-2.8%, -0.9%] 3
Improvements ✅
(secondary)
-2.1% [-3.2%, -1.0%] 2
All ❌✅ (primary) -0.8% [-2.8%, 2.8%] 4

Cycles

Results (primary 2.8%, 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)
2.8% [1.7%, 4.2%] 3
Regressions ❌
(secondary)
5.6% [2.0%, 10.1%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.0% [-5.2%, -3.4%] 4
All ❌✅ (primary) 2.8% [1.7%, 4.2%] 3

Binary size

Results (primary 1.2%, secondary 1.5%)

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

mean range count
Regressions ❌
(primary)
1.4% [0.0%, 7.6%] 34
Regressions ❌
(secondary)
1.5% [0.0%, 7.6%] 9
Improvements ✅
(primary)
-0.3% [-0.4%, -0.3%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.2% [-0.4%, 7.6%] 38

Bootstrap: 474.243s -> 475.084s (0.18%)
Artifact size: 390.98 MiB -> 390.76 MiB (-0.06%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 6, 2025
@@ -1,4 +1,4 @@
error: Undefined Behavior: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1
error: Undefined Behavior: constructing invalid value at .0.0: encountered 0, but expected something greater or equal to 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use .0 for pattern types? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In const eval diagnostics we use that for accessing wide pointer components, too

There's probably lots to improve here, but I just made pattern types behave the same

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor Author

oli-obk commented Dec 3, 2025

@bors try @rust-timer queue (local perf couldn't download the try build artifacts anymore)

@rust-timer
Copy link
Collaborator

Error occurred while parsing comment: Invalid command argument (local (there may be no spaces around the = character)

rust-bors bot added a commit that referenced this pull request Dec 3, 2025
[perf] Start using pattern types in libcore
@rust-bors

This comment has been minimized.

@mati865
Copy link
Member

mati865 commented Dec 3, 2025

rust-timer doesn't like when you add string that isn't a hash to queue.

@rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Feb 10, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 10, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 11, 2026

So... we do spend a little bit more time in borrowck proving obligations, but the major part of the regressions is in LLVM and codegen. I presume it now just has more range information available, causing more optimizations to do analyses and/or store metadata during opts (the latter is hinted at but a significant increase in malloc/free calls:

The only regression that reliably shows up is html5ever at 7% in release mode and 1-3% everywhere else. I'm assuming significant usage of NonZero along with some usage that make our mir-opts move the field out of the wrapper type directly into MIR, which amusingly we don't have any mir-opt tests for.

< 70,692,743  ???:
   4,399,825    <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
   3,818,415    <rustc_borrowck::type_check::TypeChecker>::fully_perform_op::<rustc_middle::ty::Ty, rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::Normalize<rustc_middle::ty::Ty>>>
   2,591,624    rustc_mir_transform::simplify::simplify_cfg
   2,454,984    <rustc_mir_build::builder::Builder>::test_candidates
   2,157,254    <rustc_borrowck::type_check::TypeChecker>::prove_trait_ref
   2,011,092    rustc_borrowck::borrowck_check_region_constraints
   1,981,868    free
   1,966,619    rustc_borrowck::get_flow_results
   1,938,014    malloc_default
   1,825,496    tcache_bin_flush_small
  -1,628,298    llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::BatchAAResults*, llvm::CodeGenOptLevel)
   1,549,788    rustc_mir_transform::validate::validate_types
   1,366,632    <rustc_trait_selection::traits::fulfill::FulfillmentContext<rustc_infer::traits::engine::ScrubbedTraitError> as rustc_infer::traits::engine::TraitEngine<rustc_infer::traits::engine::ScrubbedTraitError>>::evaluate_obligations_error_on_ambiguity
   1,360,948    malloc
   1,300,755    <rustc_mir_transform::known_panics_lint::ConstPropagator as rustc_middle::mir::visit::Visitor>::visit_assign
   1,265,439    rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::GenericBuilder<rustc_codegen_llvm::context::FullCx>>
   1,178,031    <rustc_mir_transform::elaborate_drops::ElaborateDrops as rustc_mir_transform::pass_manager::MirPass>::run_pass

most of the smaller regressions are net-positive in execution time and look like just random reshufflings of cgus.

With all that said, I think we should just merge it

r? compiler

@rustbot rustbot assigned dianqk and unassigned scottmcm Feb 11, 2026
@dianqk
Copy link
Member

dianqk commented Feb 12, 2026

Things may have changed after LLVM 21.
@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 12, 2026
Start using pattern types in libcore (NonZero and friends)
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 12, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 12, 2026

☀️ Try build successful (CI)
Build commit: 2911809 (2911809bfdef24e9b84a988f3fa70012c82c99ba, parent: 7057231bd78d6c7893f905ea1832365d4c5efe17)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2911809): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@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)
1.9% [0.1%, 3.8%] 12
Regressions ❌
(secondary)
1.3% [0.1%, 3.6%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 2
All ❌✅ (primary) 1.9% [0.1%, 3.8%] 12

Max RSS (memory usage)

Results (primary -1.9%, secondary 0.5%)

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

mean range count
Regressions ❌
(primary)
1.4% [1.4%, 1.4%] 1
Regressions ❌
(secondary)
2.3% [1.6%, 3.7%] 6
Improvements ✅
(primary)
-5.2% [-5.2%, -5.2%] 1
Improvements ✅
(secondary)
-4.8% [-5.2%, -4.4%] 2
All ❌✅ (primary) -1.9% [-5.2%, 1.4%] 2

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)
2.3% [2.3%, 2.4%] 2
Regressions ❌
(secondary)
3.9% [2.6%, 4.7%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.3% [-5.8%, -2.0%] 4
All ❌✅ (primary) 2.3% [2.3%, 2.4%] 2

Binary size

Results (primary 4.2%, secondary 6.2%)

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

mean range count
Regressions ❌
(primary)
4.2% [0.2%, 7.7%] 11
Regressions ❌
(secondary)
6.2% [4.8%, 7.7%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 4.2% [0.2%, 7.7%] 11

Bootstrap: 476.438s -> 475.444s (-0.21%)
Artifact size: 397.88 MiB -> 395.86 MiB (-0.51%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 12, 2026
@dianqk
Copy link
Member

dianqk commented Feb 12, 2026

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 12, 2026

📌 Commit 85e8282 has been approved by dianqk

It is now in the queue for this repository.

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

This comment has been minimized.

@rust-bors rust-bors bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 12, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 12, 2026

☀️ Test successful - CI
Approved by: dianqk
Duration: 4h 6m 15s
Pushing bb8b30a to main...

@rust-bors rust-bors bot merged commit bb8b30a into rust-lang:main Feb 12, 2026
13 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 12, 2026
@github-actions
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 7ad4e69 (parent) -> bb8b30a (this PR)

Test differences

Show 2 test diffs

2 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard bb8b30a5fce59f5d3d17a8f010601c59f0f19d79 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-aarch64-apple: 1h 46m -> 2h 57m (+65.7%)
  2. aarch64-apple: 3h 6m -> 3h 58m (+27.7%)
  3. dist-apple-various: 2h -> 2h 19m (+15.7%)
  4. pr-check-1: 32m 30s -> 27m 27s (-15.5%)
  5. i686-gnu-2: 1h 45m -> 1h 30m (-15.0%)
  6. i686-gnu-nopt-1: 2h 19m -> 2h (-13.9%)
  7. x86_64-gnu-nopt: 2h 25m -> 2h 6m (-13.1%)
  8. x86_64-gnu-llvm-21-3: 1h 51m -> 1h 38m (-12.2%)
  9. x86_64-gnu-llvm-21-2: 1h 26m -> 1h 37m (+11.9%)
  10. x86_64-gnu-tools: 1h 2m -> 56m 34s (-9.9%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bb8b30a): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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)
1.9% [0.1%, 3.8%] 12
Regressions ❌
(secondary)
2.2% [0.1%, 3.6%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 2
All ❌✅ (primary) 1.9% [0.1%, 3.8%] 12

Max RSS (memory usage)

Results (primary 0.7%, secondary -0.7%)

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

mean range count
Regressions ❌
(primary)
2.1% [1.0%, 3.5%] 4
Regressions ❌
(secondary)
1.7% [1.7%, 1.8%] 2
Improvements ✅
(primary)
-5.1% [-5.1%, -5.1%] 1
Improvements ✅
(secondary)
-3.1% [-4.1%, -2.1%] 2
All ❌✅ (primary) 0.7% [-5.1%, 3.5%] 5

Cycles

Results (primary 2.6%, 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)
2.6% [2.0%, 3.7%] 9
Regressions ❌
(secondary)
3.8% [2.6%, 4.5%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.1% [-6.6%, -2.2%] 3
All ❌✅ (primary) 2.6% [2.0%, 3.7%] 9

Binary size

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)
4.2% [0.1%, 7.6%] 11
Regressions ❌
(secondary)
6.2% [4.8%, 7.6%] 2
Improvements ✅
(primary)
-0.1% [-0.1%, -0.0%] 33
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 23
All ❌✅ (primary) 1.0% [-0.1%, 7.6%] 44

Bootstrap: 480.915s -> 480.389s (-0.11%)
Artifact size: 398.15 MiB -> 396.04 MiB (-0.53%)

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

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants