Uh oh!
There was an error while loading. Please reload this page.
Avoid Iterator::last - #101690
Conversation
rust-highfive
commented
Sep 11, 2022
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
leonardo-m
commented
Sep 11, 2022
If this is a problem, has Clippy a "performance" suggestion about this? (Dogfooding compiler improvementes into Clippy is generally a good idea). |
kadiwa4
commented
Sep 11, 2022
No, it doesn't look like a lint for that exists. |
Kobzol
commented
Sep 12, 2022
@bors try @rust-timer queue |
rust-timer
commented
Sep 12, 2022
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
bors
commented
Sep 12, 2022
⌛ Trying commit 66211d8 with merge 5bcf9d36a0c3bd58c90f463f91304174af29e909... |
bors
commented
Sep 12, 2022
☀️ Try build successful - checks-actions |
rust-timer
commented
Sep 12, 2022
Queued 5bcf9d36a0c3bd58c90f463f91304174af29e909 with parent fa521a4, future comparison URL. |
rust-timer
commented
Sep 12, 2022
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 |
oli-obk
commented
Sep 13, 2022
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 |
Kobzol
commented
Sep 13, 2022
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. |
oli-obk
commented
Sep 13, 2022
Oh right. Still, these changes are not in hot paths. It's a good cleanup either way. @bors r+ rollup |
bors
commented
Sep 13, 2022
…-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
FilterandMapuse the default implementation ofIterator::lastwhich 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 tolastresults in slight performance improvements.