-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 Iterator::next_chunk
#93700
Add Iterator::next_chunk
#93700
Conversation
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
59f02bf
to
d278874
Compare
What does the generated assembly look like for iterators with some adapters? Since it's only the default implementation I suspect it ends up fairly suboptimal for some, e.g. What are the expected use-cases outside performance optimizations? |
I do like this, but sometimes new methods on @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit d278874c383c78c184489bcdcf88000e5f2a81e4 with merge 105d69820468588050de7ef014893e36f8d31852... |
☀️ Try build successful - checks-actions |
Queued 105d69820468588050de7ef014893e36f8d31852 with parent f624427, future comparison URL. |
Finished benchmarking commit (105d69820468588050de7ef014893e36f8d31852): comparison url. Summary: This benchmark run shows 10 relevant improvements 🎉 but 6 relevant regressions 😿 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. 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 led to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never |
d278874
to
f655cf2
Compare
☔ The latest upstream changes (presumably #94103) made this pull request unmergeable. Please resolve the merge conflicts. |
Finished benchmarking commit (a84461c4ba181989b800141ff8fca18a6123e9f0): comparison url. Instruction count
Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. 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 Footnotes |
@bors r+ |
📌 Commit bbdff1f has been approved by |
Doesn't this also basically implement what is essentially an array collect? cc #81615 |
⌛ Testing commit bbdff1f with merge 5f45e327138716439a8956ac674991c9e6feb833... |
💔 Test failed - checks-actions |
@CryZe To some extent yes, but by being |
@bors retry |
☀️ Test successful - checks-actions |
Finished benchmarking commit (1aabd8a): comparison url. Instruction count
Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
In my code base I've seen that in most cases I need a proper collect_array that includes a test of empty iterable afterwards (and sometimes a collect_slice) instead of a next_chunk. |
Is it a good idea to add next_chunk to the stdlib? Beside me finding zero usages for it so far in my codebase, I suspect most people will forget to put a line like that assert_eq!(iter.next_chunk::<4>().unwrap_err().as_slice(), &[]) in their code, so I suspect this will cause bugs in future Rust code. |
@leonardo-m since the PR already is merged the tracking issue (#98326) is a better place to discuss this. |
People also forget to check https://doc.rust-lang.org/std/slice/struct.ChunksExact.html#method.remainder, so this seems perfectly consistent with existing precedent. (Also, I suspect this might be a building block API -- the place for iterators to do it more efficiently than general approaches -- that then gets usually consumed by an |
See also #92393
Prior art
Itertools::next_tuple()
Unresolved questions
next_chunk_back
toDoubleEndedIterator
?next_array()
ornext_array_chunk
?