Releases: subpath/weighted_trie
Releases · subpath/weighted_trie
v0.2.0
Full Changelog: v0.1.4...v0.2.0
Optimizations
- String interning: Each word stored once, nodes use indices
- Packed suggestions: Weight+index packed into u64 (bit manipulation)
- compact_str: 12-byte strings vs 24-byte std String
- SmallVec: Stack allocation for small collections (≤2 suggestions, ≤4 children)
- Arena allocation: All nodes in Vec, use indices instead of Box pointers
- hashbrown HashMap: Faster than std HashMap
- Pre-allocation: Vec capacity = words × 2 (avoids reallocations)
- shrink_to_fit: Removes over-allocation after build
- Top-K limiting: 10 suggestions per node max
- Deduplication: Automatic on insert
Benchmarks
Performance
Single insert: 272 ns
Lookup (per query): 244 ns
Build (100K words): 33.7 ms
Insert 100K (incremental): 32.6 ms
Memory Footprint
Dataset Memory Bytes/Word
------------------------------------
10K 2.4 MB 254
50K 13.0 MB 273
100K 29.5 MB 309
500K 130.8 MB 274
1M 231.4 MB 243
v0.1.4
Almost 3x speedup in lookup time 🚀
Full Changelog: v0.1.3...v0.1.4
v0.1.3
v0.1.2
Full Changelog: v0.1.1...v0.1.2
v0.1.1
Full Changelog: v0.1.0...v0.1.1
v0.1.0
Full Changelog: https://github.com/subpath/weighted_trie/commits/v0.1.0