Comments (3)
We can't use Allocator::grow
because growing the table requires re-hashing all elements and moving them into new slots. We need the destination table to be empty when we do this.
I don't think there is anything actionable that we can do here. Fundamentally, if you have a short-lived hash table then you should pre-allocate it using with_capacity
to avoid unnecessary allocations while the table is being filled in.
from hashbrown.
Here's the benchmark results on the M1
test tests::insert_hashmap_0128 ... bench: 3,464 ns/iter (+/- 33)
test tests::insert_hashmap_0256 ... bench: 6,976 ns/iter (+/- 169)
test tests::insert_hashmap_0512 ... bench: 14,142 ns/iter (+/- 363)
test tests::insert_hashmap_1024 ... bench: 28,418 ns/iter (+/- 776)
test tests::insert_hashmap_2048 ... bench: 56,802 ns/iter (+/- 1,536)
test tests::insert_hashmap_4096 ... bench: 115,039 ns/iter (+/- 1,993)
test tests::insert_hashmap_8192 ... bench: 230,840 ns/iter (+/- 2,915)
test tests::insert_hashmap_arena_0128 ... bench: 3,334 ns/iter (+/- 51)
test tests::insert_hashmap_arena_0256 ... bench: 6,745 ns/iter (+/- 88)
test tests::insert_hashmap_arena_0512 ... bench: 13,930 ns/iter (+/- 352)
test tests::insert_hashmap_arena_1024 ... bench: 28,146 ns/iter (+/- 748)
test tests::insert_hashmap_arena_2048 ... bench: 56,707 ns/iter (+/- 1,419)
test tests::insert_hashmap_arena_4096 ... bench: 114,617 ns/iter (+/- 1,487)
test tests::insert_hashmap_arena_8192 ... bench: 230,836 ns/iter (+/- 2,066)
test tests::insert_hashtrie_0128 ... bench: 3,960 ns/iter (+/- 72)
test tests::insert_hashtrie_0256 ... bench: 8,371 ns/iter (+/- 74)
test tests::insert_hashtrie_0512 ... bench: 19,459 ns/iter (+/- 983)
test tests::insert_hashtrie_1024 ... bench: 38,765 ns/iter (+/- 1,812)
test tests::insert_hashtrie_2048 ... bench: 80,342 ns/iter (+/- 3,970)
test tests::insert_hashtrie_4096 ... bench: 170,788 ns/iter (+/- 13,437)
test tests::insert_hashtrie_8192 ... bench: 359,124 ns/iter (+/- 27,457)
test tests::insert_hashtrie_arena_0128 ... bench: 906 ns/iter (+/- 120)
test tests::insert_hashtrie_arena_0256 ... bench: 2,208 ns/iter (+/- 69)
test tests::insert_hashtrie_arena_0512 ... bench: 4,829 ns/iter (+/- 58)
test tests::insert_hashtrie_arena_1024 ... bench: 11,538 ns/iter (+/- 186)
test tests::insert_hashtrie_arena_2048 ... bench: 27,082 ns/iter (+/- 581)
test tests::insert_hashtrie_arena_4096 ... bench: 59,013 ns/iter (+/- 1,308)
test tests::insert_hashtrie_arena_8192 ... bench: 132,295 ns/iter (+/- 11,462)
from hashbrown.
Makes sense. Thanks for clarifying!
Feel free to close this, if you feel like there's nothing that can be done.
from hashbrown.
Related Issues (20)
- `hashbrown` fails to compile as a transitive dependency HOT 2
- allocator-api2 default-feature? HOT 2
- Compiling hashbrown 0.14.2 for aarch64-unknown-linux-gnu with "target-cpu=cortex-a53" generates illegal instructions HOT 2
- Switching to GxHash? HOT 9
- Feature: increase capacity according to the actual size returned by the allocator HOT 2
- Hashbrown crash due to bad malloc HOT 1
- 0.14.3 - no method named `clear` found for struct `HashMap` in the current scope HOT 5
- Benchmark biaised due to no fence around input
- assertion failed: buckets.is_power_of_two() HOT 8
- Build breaks on nightly due to use of `stdsimd` rust feature in ahash 0.8.6 HOT 2
- Was swap-remove behavior ever considered when removing entries? HOT 10
- Consider returning to 1.63.0 MSRV HOT 1
- How to calculate the size of the hashbrown::HashMap at runtime? HOT 1
- LLVM failed to use the knowledge from a never-overflow assumption HOT 13
- Library test `map::test_map::test_clone_from_memory_leaks` errors with using uninitialized data under valgrind and miri
- update to ahash 0.8.7 or after to use new stdsimd feature portable_simd HOT 1
- Do not grow the raw table when lots of deletion and insertion is performed HOT 3
- Unsound usages of unsafe implementation from `usize` to `T` HOT 2
- Support lower maximum size
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hashbrown.