Hasty Briefsbeta

Bilingual

Comprehensive C++ Hashmap Benchmarks (2022)

2 days ago
  • #Benchmark
  • #Performance
  • #C++
  • The benchmark evaluates 29 different C++ hashmap implementations with various allocators and hashes, totaling 174 combinations and 1914 benchmark evaluations.
  • Key benchmarks include copying maps, inserting and erasing elements, random insert and access, iteration, and find operations for both integers and strings.
  • Performance varies significantly across implementations, with some excelling in specific areas like search speed, memory usage, or insertion/erasure efficiency.
  • The author's own implementation, ankerl::unordered_dense::map, is highlighted as an excellent all-rounder with fast search and iteration speeds.
  • Google's absl::flat_hash_map and absl::node_hash_map are noted for their performance, especially in large maps, but are sensitive to hash quality.
  • Boost's unordered_map shows significant improvements in lookup speed over std::unordered_map but is slower in insert, erase, and copy operations.
  • Specialized allocators like PoolAllocator can improve memory usage and performance for node-based containers.
  • Hash quality significantly impacts performance, with std::hash and boost::hash performing poorly for integral types due to lack of avalanching.
  • The benchmark infrastructure uses a controlled environment with isolated cores, disabled frequency scaling, and specific compiler flags to ensure consistency.
  • The results are presented in a detailed table, allowing users to sort and filter based on specific performance metrics.