Skip to content

reduce perf impact of scalar size checks - #161456

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:scalar-size-check
Aug 28, 2026
Merged

reduce perf impact of scalar size checks#161456
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:scalar-size-check

Conversation

@RalfJung

@RalfJung RalfJung commented Aug 21, 2026

Copy link
Copy Markdown
Member

View all comments

Attempting to undo the perf regression in #161238.

@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 21, 2026
@RalfJung

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

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 21, 2026
try to reduce impact of scalar size checks
@rust-bors

rust-bors Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 5e1a5a6 (5e1a5a6052b5d6d684b94bb5c2842e53fa58a153)
Base parent: 16a623a (16a623ad672a92409b5c04beb303583c6cf72a7e)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (5e1a5a6): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.4%, -0.2%] 6
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.3% [-0.4%, -0.2%] 6

Max RSS (memory usage)

Results (primary 2.1%, secondary 2.1%)

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

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

Cycles

Results (primary 2.4%, secondary 6.9%)

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

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

Binary size

Results (primary 0.1%, secondary 0.1%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.2%] 116
Regressions ❌
(secondary)
0.1% [0.0%, 0.2%] 121
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.2%] 116

Bootstrap: 457.604s -> 457.186s (-0.09%)
Artifact size: 398.89 MiB -> 398.99 MiB (0.03%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 21, 2026
@RalfJung

Copy link
Copy Markdown
Member Author

Looks like the right direction, but not quite enough. So I guess it's code size here, where previously we just constructed a little struct and now we invoke the panic machinery.

@RalfJung

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

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 21, 2026
try to reduce impact of scalar size checks
@rust-bors

rust-bors Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: d8dc741 (d8dc741a46ffa8d3eb34711760f4c5154fecbe5c)
Base parent: b662191 (b66219142c937562f2ff8e083be2a2b25b20199e)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (d8dc741): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.5%, -0.4%] 6
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-0.5%, -0.4%] 6

Max RSS (memory usage)

Results (primary 2.9%, secondary -1.3%)

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

mean range count
Regressions ❌
(primary)
2.9% [2.5%, 3.3%] 2
Regressions ❌
(secondary)
2.9% [2.9%, 2.9%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.5% [-5.5%, -5.5%] 1
All ❌✅ (primary) 2.9% [2.5%, 3.3%] 2

Cycles

Results (primary -2.6%, 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)
1.6% [1.6%, 1.6%] 1
Improvements ✅
(primary)
-2.6% [-3.0%, -2.1%] 2
Improvements ✅
(secondary)
-3.1% [-3.6%, -2.7%] 3
All ❌✅ (primary) -2.6% [-3.0%, -2.1%] 2

Binary size

Results (primary -0.1%, secondary -0.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)
- - 0
Improvements ✅
(primary)
-0.1% [-0.2%, -0.0%] 93
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.0%] 66
All ❌✅ (primary) -0.1% [-0.2%, -0.0%] 93

Bootstrap: 470.067s -> 467.991s (-0.44%)
Artifact size: 400.02 MiB -> 400.02 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 21, 2026
@RalfJung

Copy link
Copy Markdown
Member Author

That's at least reasonably close to the red numbers in the original PR I think.
r? @petrochenkov
since you reviewed the previous PR

@RalfJung
RalfJung marked this pull request as ready for review August 21, 2026 18:17
@rustbot

rustbot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @oli-obk, @lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 21, 2026
@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 27, 2026
@rust-bors

rust-bors Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#161871), which was unapproved.

View changes since this unapproval

@rustbot

rustbot commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

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.

@RalfJung

Copy link
Copy Markdown
Member Author

I doubt that this PR could do anything to affect the scalable vector tests.

@bors try jobs=aarch64-gnu

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 27, 2026
reduce perf impact of scalar size checks


try-job: aarch64-gnu
@RalfJung

Copy link
Copy Markdown
Member Author

Yeah it was the other one.
@bors r=petrochenkov

@rust-bors

rust-bors Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d802d17 has been approved by petrochenkov

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 27, 2026
@rust-bors

rust-bors Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: e4be0ad (e4be0adb48accec0cd74df0b9fd13f216e808948)
Base parent: e457a7b (e457a7b0d326d67b4322ef0d11bd715cfaeda48f)

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Aug 27, 2026
…ochenkov

reduce perf impact of scalar size checks

Attempting to undo the perf regression in rust-lang#161238.
rust-bors Bot pushed a commit that referenced this pull request Aug 28, 2026
Rollup of 14 pull requests

Successful merges:

 - #150075 (Implement clamp_to)
 - #159103 (fix(reborrow): recursive implementation)
 - #160848 (std: avoid aliasing violations when wrapping opaque C types)
 - #161421 (Include startup crt objects on WASI for more outputs)
 - #161805 (Prefer ambiguous candidates when deduplicating traits in scope, so `ambiguous_glob_imported_traits` doesn't depend on import order)
 - #161862 (Put data segment in specified section with link_section on wasm)
 - #161866 (delegation: add tests fixating behavior of delegating to default trait implementations)
 - #161456 (reduce perf impact of scalar size checks)
 - #161666 (Print vendor instructions in `x vendor`)
 - #161730 (Improve type mismatch annotation for lets with block-wrapped initializers)
 - #161828 (Never type after-stabilization cleanup)
 - #161860 (atomicptr.rs test: remove unused import)
 - #161870 (bind to [::1] instead of 127.0.0.1 in documentation examples for v6 UDP methods)
 - #161876 (rustdoc: Correctly handle when a macro generates multiple items in `--generate-macro-expansion`)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 28, 2026
…ochenkov

reduce perf impact of scalar size checks

Attempting to undo the perf regression in rust-lang#161238.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 28, 2026
…ochenkov

reduce perf impact of scalar size checks

Attempting to undo the perf regression in rust-lang#161238.
rust-bors Bot pushed a commit that referenced this pull request Aug 28, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #158609 (Update sccache to 0.16.0)
 - #150075 (Implement clamp_to)
 - #159103 (fix(reborrow): recursive implementation)
 - #160562 (add target feature ABI checks for SPARC)
 - #160848 (std: avoid aliasing violations when wrapping opaque C types)
 - #161421 (Include startup crt objects on WASI for more outputs)
 - #161805 (Prefer ambiguous candidates when deduplicating traits in scope, so `ambiguous_glob_imported_traits` doesn't depend on import order)
 - #161862 (Put data segment in specified section with link_section on wasm)
 - #161866 (delegation: add tests fixating behavior of delegating to default trait implementations)
 - #161456 (reduce perf impact of scalar size checks)
 - #161528 (Add regression test to ensure optimal compilation)
 - #161666 (Print vendor instructions in `x vendor`)
 - #161730 (Improve type mismatch annotation for lets with block-wrapped initializers)
 - #161828 (Never type after-stabilization cleanup)
 - #161859 (Do not optimize MIR for comptime ConstFns)
 - #161860 (atomicptr.rs test: remove unused import)
 - #161870 (bind to [::1] instead of 127.0.0.1 in documentation examples for v6 UDP methods)
 - #161876 (rustdoc: Correctly handle when a macro generates multiple items in `--generate-macro-expansion`)
 - #161889 (Add link to ownership section in ptr::read docs)
 - #161890 (rustdoc: some clarifying comments)
 - #161891 (Mark `extern_item_impls` feature as incomplete)

Failed merges:

 - #161702 (Use `drop_guard` in some places in {core,alloc,std})
rust-bors Bot pushed a commit that referenced this pull request Aug 28, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #150075 (Implement clamp_to)
 - #159103 (fix(reborrow): recursive implementation)
 - #160562 (add target feature ABI checks for SPARC)
 - #160848 (std: avoid aliasing violations when wrapping opaque C types)
 - #161421 (Include startup crt objects on WASI for more outputs)
 - #161805 (Prefer ambiguous candidates when deduplicating traits in scope, so `ambiguous_glob_imported_traits` doesn't depend on import order)
 - #161862 (Put data segment in specified section with link_section on wasm)
 - #161866 (delegation: add tests fixating behavior of delegating to default trait implementations)
 - #157218 (Track items behind `cfg_select` in the same way we do for `cfg`)
 - #161456 (reduce perf impact of scalar size checks)
 - #161528 (Add regression test to ensure optimal compilation)
 - #161666 (Print vendor instructions in `x vendor`)
 - #161730 (Improve type mismatch annotation for lets with block-wrapped initializers)
 - #161828 (Never type after-stabilization cleanup)
 - #161859 (Do not optimize MIR for comptime ConstFns)
 - #161860 (atomicptr.rs test: remove unused import)
 - #161870 (bind to [::1] instead of 127.0.0.1 in documentation examples for v6 UDP methods)
 - #161876 (rustdoc: Correctly handle when a macro generates multiple items in `--generate-macro-expansion`)
 - #161889 (Add link to ownership section in ptr::read docs)
 - #161890 (rustdoc: some clarifying comments)
 - #161891 (Mark `extern_item_impls` feature as incomplete)

Failed merges:

 - #161702 (Use `drop_guard` in some places in {core,alloc,std})
@rust-bors
rust-bors Bot merged commit 0d704a3 into rust-lang:main Aug 28, 2026
14 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Aug 28, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 28, 2026
Rollup merge of #161456 - RalfJung:scalar-size-check, r=petrochenkov

reduce perf impact of scalar size checks

Attempting to undo the perf regression in #161238.
@RalfJung
RalfJung deleted the scalar-size-check branch August 29, 2026 21:07
artefactop added a commit to ryolang/ryo that referenced this pull request Sep 4, 2026
Codify the lesson from rust-lang/rust#161456: debug_assert! for
internal invariants, #[cold] outlined panics for unavoidable
always-on checks in hot paths, and type-level invariants
(NonZero* newtypes) over runtime checks.
artefactop added a commit to ryolang/ryo that referenced this pull request Sep 5, 2026
…n-off, ownership unreachable (#136)

* docs: add Gleam/BEAM cross-reference to concurrency plan

Annotate docs/dev/concurrency.md with lessons from how Gleam layers
typed concurrency APIs (Subject, Selector, process.call, supervisors)
over BEAM/ERTS lightweight processes, mapped onto the plan's sections:
linked-by-default spawns vs task.scope, composable selectors vs select,
dirty schedulers vs the #[blocking]/system-coroutine split, mandatory
call timeouts, backpressure advantage of the four channel modes, and
the preemptive-vs-cooperative scheduling divergence as a known risk.

* docs: trim pipeline_alignment.md to pending work and future considerations

All five phases of the Zig-alignment plan have shipped (diagnostics,
InternPool, UIR/TIR split, lazy worklist Sema), so the phase-by-phase
plan text is removed (preserved in git history). The doc now tracks
only the pending substrate features (comptime, generics, inline
expansion), the deferred TypeId enum decision (I-018), a new section
on divergence from Zig (ownership pass, pre-codegen optimization
passes), the one still-valid risk register entry (parallel Sema), and
the out-of-scope future considerations.

Sweep stale citations to the removed sections in code comments and
docs (CLAUDE.md, docs/dev/README.md, architecture_analysis.md,
ISSUES.md I-018) so every committed file stays self-contained.

* docs: trim view-materialization doc to pending work, schedule gaps on roadmap

ryo-view-materialization.md now tracks only the four pending items
(slice[T] materialization, From/Materialize + Clone traits,
bytes.copy_into, E0034 machine-applicable suggestion); shipped design
record lives in roadmap M8.4.1.2/M8.4.2 and final spec 3.4.1.

Roadmap: add the slice[T] bit-copy materialization task to M21, the
From/Materialize + Clone migration bullet to Traits & Generics, and an
E0034 suggestion row to the Phase 5 deferred table. Fix the M8.4.2
completion date (2026-09-01, PR #133) and the README index row.

* docs: fold installation.md into roadmap M26.5 and delete the doc

The dev doc duplicated Milestone 26.5 almost entirely and was stale
(phantom Milestone 20.5, dead ryolang.org URL, false claim that
install.sh edits shell rc files). Absorbed its unique content into the
roadmap: ~/.ryo/ layout, uninstall procedure, post-v0.1 brew/winget/
Docker distribution, Intel Mac exclusion, ryo upgrade scoping and
Windows self-replace caveat. Marked install.sh done with its real
behavior, fixed the working install URL and the toolchain.rs path.
Musl release artifacts stay gated on the open musl evaluation in
ISSUES.md; download integrity is already filed there too.

* test: add Python to string_building benchmark

Add string_building.py (same 50,000-iteration s += "x" concat loop) and
wire python3 into run_benchmarks.sh. Refresh README results: CPython 3.14.7
runs 36.6 ms, ~25x slower than Rust and ~2x slower than Ryo's compiled
O(n^2) concat, with 14.72 MB peak RSS.

* docs: move pl references to docs/dev/pl_references/ and drop _reference postfix

* spec: catch up to M8.4.2, drop println, strip roadmap status

- Header: pre-alpha implementation phase; spec holds the final
  design, implementation status lives in the roadmap
- Document shipped bytes/bytesview surface: bytesview in the
  view-type list, bytes(bview) materialization + W0003, print of
  bytes/bytesview via escaped repr, owner<->view equality
  cross-comparison, b"..." in the literal list
- Remove println: single print(_ s: str, end: str = "\n") builtin
  (Python convention); println recorded under Considered/Rejected
- Fix stale claims: named/default parameters are not implemented;
  drop bytes/bytesview from Planned Future Extensions
- Spec purity: remove dev-doc citations (final spec Dn/Pn/GAP-n,
  milestone numbers, docs/dev paths), the Feature Availability
  rollout table, all Status: Planned banners, and inline v0.x
  version tags, rewording where the sentence carried design content

* chore: track deferred sema INT_MIN/-1 check and FFI audit

* fix: guard INT_MIN / -1 and % -1 signed overflow at codegen

Extends the division guard with a dividend == i64::MIN && divisor == -1
check branching to the same ryo_panic path; const_int and IntRange
elide the check when either side is proven safe. Closes I-138.

* docs: add Swift 6.3 pl reference snapshot

* fix: split runtime abort paths and make FFI null checks real

overflow_abort (u64->usize narrowing, checked_add/mul overflow) and
null_abort (null pointer at FFI entry) are now distinct from
oom_abort, and ryo_print/ryo_panic/ryo_str_from_view guard their
pointer args in release builds too. Closes I-132.

* chore: close I-127 after R5 human sign-off

Both in-tree unsafe sites carry SAFETY comments and the linked issue,
and unsafe_code = deny guards the rest of the tree. Human sign-off
recorded 2026-09-01.

* refactor: fold ownership param-map panics into trusted-producer contract

The four expect("param exists") sites now go through a shared
param_idx helper that unreachable!s, matching the sema fallthrough
sites under the documented TIR trusted-producer contract. Closes
I-155.

* chore: move div guard messages to expr.rs to fix file-length check

* chore: fix stale emit_div_zero_guard references after rename

* test: tighten overflow JIT assertions to require exit 101

* docs: point ownership references at ownership/mod.rs after the split

* docs: exempt notes.md from the dev-doc lifecycle, rename from NOTES.md

Also tracks the remaining hyphenated ryo-*.md doc names as I-168.

* docs: fix pl_references phase counts, codegen pipeline, and spec links

* docs: gate shared[T] on ARC optimizer pass, name freezing rule

- spec 5.6: promote 'sharing freezes' to the named Freezing concept;
  add weak[T]-by-default guidance and demote unowned[T] to provable
  lifetimes only (runtime-trap warning)
- roadmap: ARC optimizer is a hard gate for user-visible shared[T]
  (M22 prototype, before stdlib/benchmarks); add debug-mode shared[T]
  cycle detector to the Phase 5 gap table (semantics unchanged)
- concurrency.md: fold channel modes, cancellation sources, async
  destructors, memory model, and with-block guard rules into spec
  pointers (9.2.2/9.2.5/9.2.6/9.3.2/14.5.4)
- spec: channel mode table, try_send/try_recv, close semantics, 9.2.6
  memory model, async destructors, cancel/cancel_now contract

* docs: refresh architecture analysis, absorb superseded dev docs into spec

- architecture_analysis.md: refresh to 2026-08-24 snapshot (fix/file-length-gate
  @ 333dbca); delete the dated 2026-08-20/2026-08-24 snapshots (history in git)
- unsafe.md, design_issues.md, testing.md, built_in.md, std.md,
  considerations.md, closure_representation.md: drop content now owned by the
  spec; keep status headers pointing at the owning spec sections
- docs/dev/CLAUDE.md: drop stale milestone-dependency list, note notes.md
  exemption from the dev-doc lifecycle

* docs: add R18a rule on keeping panicking checks out of hot paths

Codify the lesson from rust-lang/rust#161456: debug_assert! for
internal invariants, #[cold] outlined panics for unavoidable
always-on checks in hot paths, and type-level invariants
(NonZero* newtypes) over runtime checks.
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.

6 participants