-
-
Notifications
You must be signed in to change notification settings - Fork 15k
step_by() on new ranges is less optimized than the old ranges. #157754
Copy link
Copy link
Open
Labels
A-iteratorsArea: IteratorsArea: IteratorsA-specializationArea: Trait impl specializationArea: Trait impl specializationC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchF-new_range`#![feature(new_range)]``#![feature(new_range)]`I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Metadata
Metadata
Assignees
Labels
A-iteratorsArea: IteratorsArea: IteratorsA-specializationArea: Trait impl specializationArea: Trait impl specializationC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchF-new_range`#![feature(new_range)]``#![feature(new_range)]`I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I compiled the following code:
Ideally, both functions should compile to the same or similar assembly. Instead, the inner loop of
bis clearly worse than that ofa:Godbolt
Assembly code
I believe that this is because
step_byhas a specialized implementation for the old ranges, but not for the new ranges. See https://github.com/rust-lang/rust/blob/485ec3fbcc12fa14ef6596dabb125ad710499c9e/library/core/src/iter/adapters/step_by.rsMeta
Reproducible on godbolt with version