June 30th, 2024

Benchmarking Perfect Hashing in C++

Benchmarking perfect hashing functions in C++ using clang++-19 and g++-13 reveals mph as the fastest with limitations. Various hash function implementations are compared for lookup time, build time, and size, aiding system optimization.

Read original articleLink Icon
Benchmarking Perfect Hashing in C++

The provided information discusses benchmarking perfect hashing functions in C++ using various compilers like clang++-19 and g++-13 with different optimization flags. The benchmarks cover different hash function implementations like if_else, switch_case, map, unordered_map, boost_unordered_flat_map, gperf, frozen, and mph, each with its characteristics and performance considerations. The measurements include lookup time, build time, and binary size for different scenarios like integer to integer and string_view to integer mappings. Additionally, the parameters affecting the benchmarks, such as element size, range, length, probability, and seed, are detailed. The fastest lookup is achieved with mph, although it has specific limitations and hardware requirements. The summary also includes code snippets for mph lookup and find functions with corresponding assembly code snippets for g++. The information provides insights into optimizing system configurations for running benchmarks efficiently.

Related

Own Constant Folder in C/C++

Own Constant Folder in C/C++

Neil Henning discusses precision issues in clang when using the sqrtps intrinsic with -ffast-math, suggesting inline assembly for instruction selection. He introduces a workaround using __builtin_constant_p for constant folding optimization, enhancing code efficiency.

Group Actions and Hashing Unordered Multisets

Group Actions and Hashing Unordered Multisets

Group actions are used to analyze hash functions for unordered sets and multisets, ensuring order-agnostic hashing. By leveraging group theory, particularly abelian groups, hash functions' structure is explored, emphasizing efficient and order-independent hashing techniques.

Optimizing JavaScript for Fun and for Profit

Optimizing JavaScript for Fun and for Profit

Optimizing JavaScript code for performance involves benchmarking, avoiding unnecessary work, string comparisons, and diverse object shapes. JavaScript engines optimize based on object shapes, impacting array/object methods and indirection. Creating objects with the same shape improves optimization, cautioning against slower functional programming methods. Costs of indirection like proxy objects and function calls affect performance. Code examples and benchmarks demonstrate optimization variances.

Libc++ Hardening Modes

Libc++ Hardening Modes

The libc++ documentation details hardening modes (Unchecked, Fast, Extensive, Debug) to prevent undefined behavior. Users adjust levels via compiler options. Vendors customize modes, assertion handling, and ABI configurations for enhanced safety.

A Survey of General-Purpose Polyhedral Compilers

A Survey of General-Purpose Polyhedral Compilers

A survey of polyhedral compilers available in 2024 compares schedulers and implementations based on robustness and performance using PolyBench/C benchmarks. Key tools like Candl, Tiramisu, Polly, and PolyMage are referenced.

Link Icon 2 comments
By @MattPalmer1086 - 4 months
Hmmm... According to the benchmark configuration they used powersave mode. In general you want to use a fixed frequency when benchmarking, not frequency scaling.