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

Send VecDeque::from_iter via Vec::from_iter #105046

Merged
merged 1 commit into from
Dec 5, 2022

Conversation

scottmcm
Copy link
Member

Since it's O(1) to convert between them now, might as well reuse the logic.

Mostly for the various specializations it does, but might also save some monomorphization work if, say, people collect slice iterators into both Vecs and VecDeques.

Since it's O(1) to convert between them now, might as well reuse the logic.

Mostly for the various specializations it does, but might also save some monomorphization work if, say, people collect slice iterators into both `Vec`s and `VecDeque`s.
@rustbot
Copy link
Collaborator

rustbot commented Nov 29, 2022

r? @Mark-Simulacrum

(rustbot has picked a reviewer for you, use r? to override)

@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 Nov 29, 2022
@rustbot
Copy link
Collaborator

rustbot commented Nov 29, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@scottmcm
Copy link
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 Nov 29, 2022
@bors
Copy link
Contributor

bors commented Nov 29, 2022

⌛ Trying commit a964a37 with merge f7ad2ffb3732d494ee97cfd8458a0ab47bc56d4c...

@the8472
Copy link
Member

the8472 commented Nov 29, 2022

That should be better than using Extend but there is room for further improvement. VecDeque could do a few things better than Vec can: Collecting from vec_deq::IntoIter, from a partially consumed vec::IntoIter and VecDeque -> VecDeque in-place iteration (sadly the vec in-place iteration code wouldn't work for vec-deque without making the source contiguous first).

@bors
Copy link
Contributor

bors commented Nov 29, 2022

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

@rust-timer

This comment has been minimized.

@scottmcm
Copy link
Member Author

@the8472 Would you want to see that as part of this PR, or would it be fine to do this as-is and add the further specializations later?

(I do like the observation that vec::IntoIter -> VecDeque can be O(1) now too, without even needing data movement!)

@the8472
Copy link
Member

the8472 commented Nov 29, 2022

I was just airing some thoughts, can totally be a separate PR.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f7ad2ffb3732d494ee97cfd8458a0ab47bc56d4c): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.6% [0.5%, 0.9%] 7
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.9% [-0.9%, -0.8%] 2
Improvements ✅
(secondary)
-2.4% [-2.7%, -2.1%] 6
All ❌✅ (primary) 0.3% [-0.9%, 0.9%] 9

Max RSS (memory usage)

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

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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-4.0%, -1.5%] 10
All ❌✅ (primary) - - 0

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 30, 2022
@Mark-Simulacrum Mark-Simulacrum added the perf-regression-triaged The performance regression has been triaged. label Dec 5, 2022
@Mark-Simulacrum
Copy link
Member

perf regressions look spurious to me (mostly in noisy benchmarks).

@bors r+

@bors
Copy link
Contributor

bors commented Dec 5, 2022

📌 Commit a964a37 has been approved by Mark-Simulacrum

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 5, 2022
@bors
Copy link
Contributor

bors commented Dec 5, 2022

⌛ Testing commit a964a37 with merge 203c876...

@bors
Copy link
Contributor

bors commented Dec 5, 2022

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 203c876 to master...

1 similar comment
@bors
Copy link
Contributor

bors commented Dec 5, 2022

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 203c876 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 5, 2022
@bors bors merged commit 203c876 into rust-lang:master Dec 5, 2022
@rustbot rustbot added this to the 1.67.0 milestone Dec 5, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (203c876): 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)
1.1% [1.1%, 1.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.7% [-3.7%, -3.7%] 1
Improvements ✅
(secondary)
-6.1% [-6.1%, -6.1%] 1
All ❌✅ (primary) -1.3% [-3.7%, 1.1%] 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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.3% [-2.5%, -2.0%] 2
All ❌✅ (primary) - - 0

@rustbot rustbot removed the perf-regression Performance regression. label Dec 5, 2022
@scottmcm scottmcm deleted the vecdeque-vs-vec branch December 5, 2022 19:55
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Dec 9, 2022
…8472

Make `VecDeque::from_iter` O(1) from `vec(_deque)::IntoIter`

As suggested in rust-lang#105046 (comment) by
r? `@the8472`

`Vec` & `VecDeque`'s `IntoIter`s own the allocations, and even if advanced can be turned into `VecDeque`s in O(1).

This is just a specialization, not an API or doc commitment, so I don't think it needs an FCP.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 9, 2022
…8472

Make `VecDeque::from_iter` O(1) from `vec(_deque)::IntoIter`

As suggested in rust-lang#105046 (comment) by
r? ``@the8472``

`Vec` & `VecDeque`'s `IntoIter`s own the allocations, and even if advanced can be turned into `VecDeque`s in O(1).

This is just a specialization, not an API or doc commitment, so I don't think it needs an FCP.
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
…ulacrum

Send `VecDeque::from_iter` via `Vec::from_iter`

Since it's O(1) to convert between them now, might as well reuse the logic.

Mostly for the various specializations it does, but might also save some monomorphization work if, say, people collect slice iterators into both `Vec`s and `VecDeque`s.
thomcc pushed a commit to tcdi/postgrestd that referenced this pull request May 31, 2023
Make `VecDeque::from_iter` O(1) from `vec(_deque)::IntoIter`

As suggested in rust-lang/rust#105046 (comment) by
r? ``@the8472``

`Vec` & `VecDeque`'s `IntoIter`s own the allocations, and even if advanced can be turned into `VecDeque`s in O(1).

This is just a specialization, not an API or doc commitment, so I don't think it needs an FCP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression-triaged The performance regression has been triaged. 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

6 participants