Skip to content
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

Improve .entry() performance #108

Closed
bluss opened this issue Oct 8, 2019 · 0 comments · Fixed by #126
Closed

Improve .entry() performance #108

bluss opened this issue Oct 8, 2019 · 0 comments · Fixed by #126

Comments

@bluss
Copy link
Member

bluss commented Oct 8, 2019

In some of the benchmarks, if I replace .insert() with code based on entry, the benchmarks run slower. If we could get these to performance parity, then we can delete the .insert() code, since it is duplicated by the functionality in .entry().

To test this, you can update insert to be like this (note insert_full uses entry right now):

    pub fn insert(&mut self, key: K, value: V) -> Option<V> {
        self.insert_full(key, value).1
    }

The following is the benchmark difference I see when using entry in insert.

The hashmap benchmarks can be ignored - ordermap is the interesting part. (The hashmap benchmarks are controls.)

Change from before to after.

 name                                   63 ns/iter  62 ns/iter  diff ns/iter  diff % 
 insert_hashmap_100_000                 2,488,863   2,504,113         15,250   0.61% 
 insert_hashmap_10_000                  214,543     221,693            7,150   3.33% 
 insert_hashmap_150                     3,210       3,339                129   4.02% 
 insert_hashmap_int_bigvalue_10_000     262,701     264,518            1,817   0.69% 
 insert_hashmap_str_10_000              236,377     247,805           11,428   4.83% 
 insert_hashmap_string_10_000           1,117,104   1,148,170         31,066   2.78% 
 insert_hashmap_string_oneshot_10_000   1,078,875   1,085,733          6,858   0.64% 
 insert_orderedmap_100_000              2,727,119   3,874,446      1,147,327  42.07% 
 insert_orderedmap_10_000               267,361     363,741           96,380  36.05% 
 insert_orderedmap_150                  3,956       5,664              1,708  43.17% 
 insert_orderedmap_int_bigvalue_10_000  359,582     413,168           53,586  14.90% 
 insert_orderedmap_str_10_000           305,463     312,993            7,530   2.47% 
 insert_orderedmap_string_10_000        1,066,189   1,091,526         25,337   2.38%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant