Skip to content

Try to improve into_slice_range inlining#157947

Draft
saethlin wants to merge 1 commit into
rust-lang:mainfrom
saethlin:into_slice_range
Draft

Try to improve into_slice_range inlining#157947
saethlin wants to merge 1 commit into
rust-lang:mainfrom
saethlin:into_slice_range

Conversation

@saethlin

Copy link
Copy Markdown
Member

This is a possible solution to #157909. I think the root problem is that LLVM sees the many non-inlinable calls to slice_index_fail and decides that the function must be a bad inlining candidate.

The other strategy I was thinking of was to call try_into_slice_range. I think deduplicating the checking logic in the source between these two functions might just be a good cleanup. But first I'm going to check if this has unexpected perf impact, because I saw mentions of RangeBounds in the compiler source.

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 16, 2026
@saethlin

Copy link
Copy Markdown
Member Author

@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 Jun 16, 2026
rust-bors Bot pushed a commit that referenced this pull request Jun 16, 2026
Try to improve into_slice_range inlining
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[TIMING:end] tool::ToolBuild { build_compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu, tool: "tidy", path: "src/tools/tidy", mode: ToolBootstrap, source_type: InTree, extra_features: [], allow_features: "", cargo_args: [], artifact_kind: Binary } -- 13.085
[TIMING:end] tool::Tidy { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu } -- 0.000
fmt check
Diff in /checkout/tests/codegen-llvm/bounds-checking/bound-tuple.rs:1:
 //@ compile-flags: -O -Zmerge-functions=disabled
 #![crate_type = "lib"]
-    
+
 use std::collections::Bound;
 use std::ops::RangeBounds;
 
Diff in /checkout/tests/codegen-llvm/bounds-checking/bound-tuple.rs:18:
     // CHECK-NOT: slice_index_fail
     // CHECK-NOT: br
     // CHECK: ret
-    if buf.len() < 4 {
-        None
-    } else {
-        Some(&buf[(Bound::Included(4), Bound::Unbounded)])
-    }
+    if buf.len() < 4 { None } else { Some(&buf[(Bound::Included(4), Bound::Unbounded)]) }
 }
 
 #[no_mangle]
fmt: checked 6912 files
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`

@rust-bors

rust-bors Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 6a83d7f (6a83d7f17c32155a5e582df6cf5dfcfa8f6d1b67, parent: 01dfd79246f1b2d5f146616deff08223a840a9ae)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (6a83d7f): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (primary 2.7%, secondary -2.5%)

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

mean range count
Regressions ❌
(primary)
2.7% [1.3%, 4.1%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) 2.7% [1.3%, 4.1%] 2

Cycles

Results (primary 2.4%, secondary -15.3%)

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.4%, 2.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-15.3% [-28.6%, -2.0%] 2
All ❌✅ (primary) 2.4% [2.4%, 2.4%] 1

Binary size

Results (primary 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.3% [0.1%, 0.9%] 4
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [-0.1%, 0.9%] 5

Bootstrap: 519.231s -> 519.196s (-0.01%)
Artifact size: 401.41 MiB -> 401.45 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. 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.

4 participants