Skip to content

Strange Rust heapsort performance difference, missed obvious llvm optimization #41448

Closed
@hirschenberger

Description

@hirschenberger

I have a strange performance difference on the standard rust heapsort implementation and a trivial modification.
The only difference is in line 15 where the right index is calculated from the left index. I thought this is a trivial optimization for a compiler.

Related gist

running 2 tests
test bench_heapsort_new ... bench:   6,950,925 ns/iter (+/- 283,342)
test bench_heapsort_old ... bench:   7,799,111 ns/iter (+/- 181,397)

rustc 1.18.0-nightly (ddc5d7bd4 2017-04-20)

rustc --test -O slice.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions