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

Add invariant to VecDeque::pop_* that len < cap if pop successful #123089

Merged
merged 1 commit into from Apr 8, 2024

Conversation

Philippe-Cholet
Copy link
Contributor

Similar to #114370 for VecDeque instead of Vec.

I initially come from rust-itertools/itertools#899 where we noticed that pop_front;push_back; was slower than expected so @scottmcm suggested I file an issue which lead to https://internals.rust-lang.org/t/vecdeque-pop-front-push-back/20483 where kornel mentionned #114334 (fixed by #114370).

This is my first time with codegen tests, I based the test on what was done for Vec.

@rustbot
Copy link
Collaborator

rustbot commented Mar 26, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Nilstrieb (or someone else) some time within the next two weeks.

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 Mar 26, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Philippe-Cholet
Copy link
Contributor Author

I just saw that the Vec::pop optimization was updated to core::hint::assert_unchecked(self.len < self.capacity()); so I probably should too.

@Nilstrieb
Copy link
Member

Yeah, that's nicer.
Gonna check compile time performance in the meantime (i don't expect many results), don't push the change until the try build is done (~2h) or it will be cancelled
@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 Mar 26, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 26, 2024
…cap, r=<try>

Add invariant to VecDeque::pop_* that len < cap if pop successful

Similar to rust-lang#114370 for VecDeque instead of Vec.

I initially come from rust-itertools/itertools#899 where we noticed that `pop_front;push_back;` was slower than expected so `@scottmcm` suggested I file an issue which lead to https://internals.rust-lang.org/t/vecdeque-pop-front-push-back/20483 where **kornel** mentionned rust-lang#114334 (fixed by rust-lang#114370).

This is my first time with codegen tests, I based the test on what was done for Vec.
@bors
Copy link
Contributor

bors commented Mar 26, 2024

⌛ Trying commit e822937 with merge debc5ab...

@bors
Copy link
Contributor

bors commented Mar 26, 2024

☀️ Try build successful - checks-actions
Build commit: debc5ab (debc5abdd3fb55de560daf90c834438ed3ebbc31)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (debc5ab): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -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)
2.6% [0.5%, 7.4%] 5
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.6% [-13.3%, -0.5%] 5
Improvements ✅
(secondary)
-2.2% [-2.9%, -1.7%] 3
All ❌✅ (primary) -0.5% [-13.3%, 7.4%] 10

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.8% [0.4%, 1.3%] 2
Regressions ❌
(secondary)
2.2% [2.0%, 2.3%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.8% [0.4%, 1.3%] 2

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

Bootstrap: 672.189s -> 671.042s (-0.17%)
Artifact size: 315.72 MiB -> 315.75 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 26, 2024
@Nilstrieb
Copy link
Member

No regression, not that I expected any change.
@bors r+ rollup=maybe

@bors
Copy link
Contributor

bors commented Mar 27, 2024

📌 Commit 083ee83 has been approved by Nilstrieb

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 Mar 27, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 27, 2024
…e_cap, r=Nilstrieb

Add invariant to VecDeque::pop_* that len < cap if pop successful

Similar to rust-lang#114370 for VecDeque instead of Vec.

I initially come from rust-itertools/itertools#899 where we noticed that `pop_front;push_back;` was slower than expected so `@scottmcm` suggested I file an issue which lead to https://internals.rust-lang.org/t/vecdeque-pop-front-push-back/20483 where **kornel** mentionned rust-lang#114334 (fixed by rust-lang#114370).

This is my first time with codegen tests, I based the test on what was done for Vec.
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 27, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#121943 (Clarify atomic bit validity)
 - rust-lang#123089 (Add invariant to VecDeque::pop_* that len < cap if pop successful)
 - rust-lang#123101 (Delegation: fix ICE on wrong `Self` instantiation)
 - rust-lang#123130 (Load missing type of impl associated constant from trait definition)
 - rust-lang#123133 (chore: fix some comments)
 - rust-lang#123136 (Some wording improvement)
 - rust-lang#123139 (`num::NonZero::get` can be 1 transmute instead of 2)
 - rust-lang#123142 (Let nils know about changes to target docs)

r? `@ghost`
`@rustbot` modify labels: rollup
@matthiaskrgr
Copy link
Member

@bors r-
#123143 (comment)

@bors bors 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 Mar 27, 2024
Similar to #114370 for VecDeque instead of Vec. It now uses `core::hint::assert_unchecked`.

#[no_mangle]
// CHECK-LABEL: @push_back_byte(
pub fn push_back_byte(v: &mut VecDeque<u8>) {
Copy link
Member

Choose a reason for hiding this comment

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

thanks for including those tests btw, having the test to make sure the above tests are correct is super important!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I merely mimicked the Vec version of this PR.
The 1st iteration was too much Vec-oriented.

@Nilstrieb
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 8, 2024

📌 Commit 7a2678d has been approved by Nilstrieb

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 8, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 8, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#115984 (extending filesystem support for Hermit)
 - rust-lang#120144 (privacy: Stabilize lint `unnameable_types`)
 - rust-lang#122807 (Add consistency with phrases "meantime" and "mean time")
 - rust-lang#123089 (Add invariant to VecDeque::pop_* that len < cap if pop successful)
 - rust-lang#123595 (Documentation fix)
 - rust-lang#123625 (Stop exporting `TypeckRootCtxt` and `FnCtxt`.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 17c94b5 into rust-lang:master Apr 8, 2024
11 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 8, 2024
Rollup merge of rust-lang#123089 - Philippe-Cholet:vecdeque_pop_assume_cap, r=Nilstrieb

Add invariant to VecDeque::pop_* that len < cap if pop successful

Similar to rust-lang#114370 for VecDeque instead of Vec.

I initially come from rust-itertools/itertools#899 where we noticed that `pop_front;push_back;` was slower than expected so `@scottmcm` suggested I file an issue which lead to https://internals.rust-lang.org/t/vecdeque-pop-front-push-back/20483 where **kornel** mentionned rust-lang#114334 (fixed by rust-lang#114370).

This is my first time with codegen tests, I based the test on what was done for Vec.
@Philippe-Cholet Philippe-Cholet deleted the vecdeque_pop_assume_cap branch April 8, 2024 16:26
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-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