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
I-slow
Issue: Problems and improvements with respect to performance of generated code.
S-needs-repro
Status: This issue has no reproduction and needs a reproduction to make progress.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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: