-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Avoid Iterator::last
#101690
Avoid Iterator::last
#101690
Conversation
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
If this is a problem, has Clippy a "performance" suggestion about this? (Dogfooding compiler improvementes into Clippy is generally a good idea). |
No, it doesn't look like a lint for that exists. |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 66211d8 with merge 5bcf9d36a0c3bd58c90f463f91304174af29e909... |
☀️ Try build successful - checks-actions |
Queued 5bcf9d36a0c3bd58c90f463f91304174af29e909 with parent fa521a4, future comparison URL. |
Finished benchmarking commit (5bcf9d36a0c3bd58c90f463f91304174af29e909): comparison URL. Overall result: no relevant changes - no action neededBenchmarking 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 Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
Footnotes |
I don't expect this to affect perfbot. We don't have runtime benchmarks for such changes, so you'll have to manually benchmark some examples |
This PR modifies the compiler code, not stdlib, so it should be visible in perfbot, or not? In any case, the changes look quite reasonable. |
Oh right. Still, these changes are not in hot paths. It's a good cleanup either way. @bors r+ rollup |
…-obk Avoid `Iterator::last` Adapters like `Filter` and `Map` use the default implementation of `Iterator::last` which is not short-circuiting (and so does `core::str::Split`). The predicate function will be run for every single item of the underlying iterator. I hope that removing those calls to `last` results in slight performance improvements.
Rollup of 5 pull requests Successful merges: - rust-lang#101602 (Streamline `AttrAnnotatedTokenStream`) - rust-lang#101690 (Avoid `Iterator::last`) - rust-lang#101700 (A `SubstitutionPart` is not considered a deletion if it replaces nothing with nothing) - rust-lang#101745 (Fix typo in concat_bytes documentation) - rust-lang#101748 (rustdoc: remove redundant CSS `#source-sidebar, #sidebar-toggle`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Adapters like
Filter
andMap
use the default implementation ofIterator::last
which is not short-circuiting (and so doescore::str::Split
). The predicate function will be run for every single item of the underlying iterator. I hope that removing those calls tolast
results in slight performance improvements.