Skip to content

std::trie: optimise insert #11546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 15, 2014
Merged

std::trie: optimise insert #11546

merged 2 commits into from
Jan 15, 2014

Conversation

huonw
Copy link
Member

@huonw huonw commented Jan 15, 2014

This reduces the number of moves/memcpy's we do, which makes insert
faster, especially in cases of keys with long equal prefixes (the
_low_bits tests):

Before:

bench_insert_large                ... bench:    553966 ns/iter (+/- 64050)
bench_insert_large_low_bits       ... bench:   1048151 ns/iter (+/- 92484)
bench_insert_small                ... bench:    168840 ns/iter (+/- 22410)
bench_insert_small_low_bits       ... bench:    185069 ns/iter (+/- 38332)

After:

bench_insert_large                ... bench:    422132 ns/iter (+/- 35112)
bench_insert_large_low_bits       ... bench:    339083 ns/iter (+/- 34421)
bench_insert_small                ... bench:    134539 ns/iter (+/- 15254)
bench_insert_small_low_bits       ... bench:     88775 ns/iter (+/- 5746)

Notably: no unsafe code.

huonw added 2 commits January 15, 2014 11:32
This reduces the number of moves/memcpy's we do, which makes insert
faster, especially in cases of keys with long equal prefixes (the
_low_bits tests):

Before:

    bench_insert_large                ... bench:    553966 ns/iter (+/- 64050)
    bench_insert_large_low_bits       ... bench:   1048151 ns/iter (+/- 92484)
    bench_insert_small                ... bench:    168840 ns/iter (+/- 22410)
    bench_insert_small_low_bits       ... bench:    185069 ns/iter (+/- 38332)

After:

    bench_insert_large                ... bench:    422132 ns/iter (+/- 35112)
    bench_insert_large_low_bits       ... bench:    339083 ns/iter (+/- 34421)
    bench_insert_small                ... bench:    134539 ns/iter (+/- 15254)
    bench_insert_small_low_bits       ... bench:     88775 ns/iter (+/- 5746)
bors added a commit that referenced this pull request Jan 15, 2014
This reduces the number of moves/memcpy's we do, which makes insert
faster, especially in cases of keys with long equal prefixes (the
\_low_bits tests):

Before:

    bench_insert_large                ... bench:    553966 ns/iter (+/- 64050)
    bench_insert_large_low_bits       ... bench:   1048151 ns/iter (+/- 92484)
    bench_insert_small                ... bench:    168840 ns/iter (+/- 22410)
    bench_insert_small_low_bits       ... bench:    185069 ns/iter (+/- 38332)

After:

    bench_insert_large                ... bench:    422132 ns/iter (+/- 35112)
    bench_insert_large_low_bits       ... bench:    339083 ns/iter (+/- 34421)
    bench_insert_small                ... bench:    134539 ns/iter (+/- 15254)
    bench_insert_small_low_bits       ... bench:     88775 ns/iter (+/- 5746)

Notably: no unsafe code.
@bors bors closed this Jan 15, 2014
@bors bors merged commit e1ebdb8 into rust-lang:master Jan 15, 2014
@huonw huonw deleted the trie-insert branch June 27, 2014 06:48
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jan 9, 2025
…curisvely (rust-lang#13891)

fixes: rust-lang#4077

Continuation of rust-lang#11546. r? @y21 if you don't mind?

changelog: [`needless_continue`] lint if the last stmt in loop is
`continue` recurisvely
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants