Skip to content
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

Removed redundant bounds checking at Split's next and next_back methods #119285

Merged
merged 2 commits into from
Dec 26, 2023

Conversation

lch361
Copy link

@lch361 lch361 commented Dec 24, 2023

Since these methods are using Iterator::rposition, which always returns a valid index, then there is no point in regular indexing with bounds checking

@rustbot
Copy link
Collaborator

rustbot commented Dec 24, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joshtriplett (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 24, 2023
@rust-log-analyzer

This comment has been minimized.

@the8472
Copy link
Member

the8472 commented Dec 24, 2023

The optimizer is often able to eliminate bounds checks based on value range information. Have you checked the assembly whether this makes any difference?

@lch361
Copy link
Author

lch361 commented Dec 24, 2023

The optimizer is often able to eliminate bounds checks based on value range information. Have you checked the assembly whether this makes any difference?

Well, I guess sometimes it fails to eliminate bound checks. I was compiling my project which uses Split with:
rustc 1.77.0-nightly (2d7be73 2023-12-23)
codegen-units = 1
opt-level = 2
lto = "fat"
And noticed that panicking code still was appearing in assembly

@lch361 lch361 changed the title Removed redundant bounds checking at Split's next and next_mut methods Removed redundant bounds checking at Split's next and next_back methods Dec 24, 2023
@rustbot rustbot added I-slow Issue: Problems and improvements with respect to performance of generated code. I-heavy Issue: Problems and improvements with respect to binary size of generated code. C-optimization Category: An issue highlighting optimization opportunities or PRs implementing such labels Dec 24, 2023
@the8472
Copy link
Member

the8472 commented Dec 25, 2023

Might affect perf.

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Dec 25, 2023

📌 Commit c082c1c has been approved by the8472

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 Dec 25, 2023
@the8472 the8472 assigned the8472 and unassigned joshtriplett Dec 25, 2023
@bors
Copy link
Collaborator

bors commented Dec 26, 2023

⌛ Testing commit c082c1c with merge f645628...

@bors
Copy link
Collaborator

bors commented Dec 26, 2023

☀️ Test successful - checks-actions
Approved by: the8472
Pushing f645628 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 26, 2023
@bors bors merged commit f645628 into rust-lang:master Dec 26, 2023
@rustbot rustbot added this to the 1.77.0 milestone Dec 26, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f645628): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.6% [1.3%, 3.7%] 3
Improvements ✅
(primary)
-4.2% [-5.7%, -2.8%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -4.2% [-5.7%, -2.8%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.9% [2.3%, 3.3%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.0%] 1

Bootstrap: 671.757s -> 671.254s (-0.07%)
Artifact size: 312.54 MiB -> 312.53 MiB (-0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-optimization Category: An issue highlighting optimization opportunities or PRs implementing such I-heavy Issue: Problems and improvements with respect to binary size of generated code. I-slow Issue: Problems and improvements with respect to performance of generated code. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

None yet

7 participants