Skip to content

Consolidate panicking functions in slice/index.rs #145137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kmeakin
Copy link
Contributor

@Kmeakin Kmeakin commented Aug 8, 2025

Consolidate all the panicking functions in slice/index.rs to use a single slice_index_fail function, similar to how it is done in str/traits.rs.

Split off from #145024

@rustbot
Copy link
Collaborator

rustbot commented Aug 8, 2025

r? @jhpratt

rustbot has assigned @jhpratt.
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

@rustbot rustbot added 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 Aug 8, 2025
@rust-log-analyzer

This comment has been minimized.

@Kmeakin Kmeakin force-pushed the km/optimize-slice-index-panicking branch from 6473bd2 to 2cc5be6 Compare August 9, 2025 00:06
@rustbot
Copy link
Collaborator

rustbot commented Aug 9, 2025

The Miri subtree was changed

cc @rust-lang/miri

@Kmeakin Kmeakin force-pushed the km/optimize-slice-index-panicking branch from 2cc5be6 to ea7033e Compare August 9, 2025 00:16
@rust-log-analyzer

This comment has been minimized.

@Kmeakin Kmeakin force-pushed the km/optimize-slice-index-panicking branch from ea7033e to 85e73f3 Compare August 9, 2025 01:16
@rust-log-analyzer

This comment has been minimized.

@xizheyin
Copy link
Member

xizheyin commented Aug 9, 2025

Thanks for the code. You could try ./x test codegen-llvm to test it locally first.
https://rustc-dev-guide.rust-lang.org/tests/intro.html

@Kmeakin Kmeakin force-pushed the km/optimize-slice-index-panicking branch from 85e73f3 to 9adc058 Compare August 9, 2025 19:16
@rust-log-analyzer

This comment has been minimized.

Consolidate all the panicking functions in `slice/index.rs` to use a single
`slice_index_fail` function, similar to how it is done in `str/traits.rs`.
@Kmeakin Kmeakin force-pushed the km/optimize-slice-index-panicking branch from 9adc058 to 5c0421d Compare August 9, 2025 21:52
@Kmeakin
Copy link
Contributor Author

Kmeakin commented Aug 10, 2025

@bors try @rust-timer queue

@rust-bors
Copy link

rust-bors bot commented Aug 10, 2025

@Kmeakin: 🔑 Insufficient privileges: not in try users

@rust-timer

This comment has been minimized.

@jhpratt
Copy link
Member

jhpratt commented Aug 11, 2025

I'm not convinced that this is an improvement, but on the other hand optimizations are weird.

@bors2 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 Aug 11, 2025
…<try>

Consolidate panicking functions in `slice/index.rs`
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 11, 2025
@rust-bors
Copy link

rust-bors bot commented Aug 11, 2025

☀️ Try build successful (CI)
Build commit: fa10c86 (fa10c86b130152ce0be5ff020bd92275c432f6b5, parent: fce0e74720d199eb7839fdb51af35ac5226da178)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (fa10c86): 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.0% [1.0%, 1.0%] 1
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
-0.7% [-1.2%, -0.3%] 5
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.1%] 2
All ❌✅ (primary) -0.5% [-1.2%, 1.0%] 6

Max RSS (memory usage)

Results (primary 1.6%, 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)
3.0% [1.1%, 4.9%] 4
Regressions ❌
(secondary)
2.4% [2.4%, 2.4%] 1
Improvements ✅
(primary)
-3.8% [-3.8%, -3.8%] 1
Improvements ✅
(secondary)
-3.7% [-4.5%, -2.5%] 4
All ❌✅ (primary) 1.6% [-3.8%, 4.9%] 5

Cycles

Results (primary 2.6%, secondary 3.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.6%, 2.6%] 1
Regressions ❌
(secondary)
4.6% [2.4%, 6.6%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) 2.6% [2.6%, 2.6%] 1

Binary size

Results (primary -0.1%, 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.1% [0.0%, 0.4%] 13
Regressions ❌
(secondary)
0.1% [0.0%, 0.2%] 2
Improvements ✅
(primary)
-0.2% [-0.4%, -0.0%] 33
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.0%] 41
All ❌✅ (primary) -0.1% [-0.4%, 0.4%] 46

Bootstrap: 464.993s -> 463.159s (-0.39%)
Artifact size: 377.36 MiB -> 377.58 MiB (0.06%)

@rustbot rustbot added the perf-regression Performance regression. label Aug 12, 2025
@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 12, 2025
@jhpratt
Copy link
Member

jhpratt commented Aug 12, 2025

While it's marked as a regression, it seems to be a very minor improvement in my eyes. But I'm no expert. cc @rust-lang/wg-compiler-performance for a second opinion. r=me if the perf is fine.

@Kobzol
Copy link
Member

Kobzol commented Aug 12, 2025

It's a wash, at least in terms of compile perf.

@bors r=jhpratt

@bors
Copy link
Collaborator

bors commented Aug 12, 2025

📌 Commit 5c0421d has been approved by jhpratt

It is now in the queue for this repository.

@bors bors 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 Aug 12, 2025
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-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. 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