removing needless .collect()
in the middle of iterator chain reduces performance significantly
#140873
Labels
C-optimization
Category: An issue highlighting optimization opportunities or PRs implementing such
E-needs-mcve
Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
I-slow
Issue: Problems and improvements with respect to performance of generated code.
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
reproduction (not minimal):
cyrgani/regulus@6c6dd75
command:
cargo run --release -- tests/programs/sorting_tests.re
The relevant part is this:
https://github.com/cyrgani/regulus/blob/6c6dd758d3eadf0383b22d1acf2d7d9ccf21ac04/regulus/src/state.rs#L60-L82
With the currently present function (also below), the given test above takes about 400ms for me.
It would seem logical now that removing the needless
.collect()
and.into_iter()
should improve runtime (or at least not change it, if the compiler can optimize the allocation out). Instead, the simpler function causes the test to take around 600ms now (50% longer):@rustbot label C-optimization I-slow E-needs-mcve
The text was updated successfully, but these errors were encountered: