October 2nd, 2024

An extensive benchmark of C and C++ hash tables

The article introduces a benchmarking suite for C and C++ hash-table libraries, evaluating performance across various configurations and operations, while noting limitations in memory usage metrics and lower load factors.

Read original articleLink Icon
An extensive benchmark of C and C++ hash tables

This article presents a comprehensive benchmarking suite for C and C++ hash-table libraries, addressing gaps in existing benchmarks that primarily focus on C++ implementations. The author, Jackson Allan, aims to highlight the performance of various hash tables under specific conditions, particularly for C programmers who may overlook newer libraries. The benchmarking setup includes three configurations: 32-bit integer keys with cheap operations, 64-bit integer keys with expensive operations, and 16-character C-string keys with costly hash and comparison functions. Each table is tested using the same hash functions, and the maximum load factor is set at 0.875. The benchmarks measure various operations, including insertion, deletion, and lookup times, while acknowledging limitations such as the exclusion of memory usage metrics and performance at lower load factors. The article also details several C++ hash tables benchmarked, including absl::flat_hash_map, ankerl::unordered_dense, and boost::unordered_flat_map, among others, each with unique design features and performance characteristics. The results aim to provide insights into the efficiency of these hash tables, particularly in scenarios relevant to developers.

- The benchmarking suite focuses on both C and C++ hash tables, addressing a lack of C table coverage.

- Three configurations are used to evaluate performance under different conditions.

- The benchmarks measure various operations, including insertion, deletion, and lookup times.

- Limitations include the exclusion of memory usage metrics and performance at lower load factors.

- Several C++ hash tables are benchmarked, each with distinct design features and performance characteristics.

Link Icon 1 comments
By @unclad5968 - 3 months
Why does the STL use such a poor implementation? It says it's performance is due to chasing pointers and allocating/freeing each node individually. Are stl implemented not able to change the details due to backwards compatibility?