Get the latest tech news

Hashed sorting is typically faster than hash tables


Benchmarks and theoretical explanation of why and when hashed radix sort beats hash tables.

Once the dataset outgrows CPU caches (often around ~1 MiB on a single core, CPU-dependent), both hashing and sorting become limited by cache-line fetch bandwidth to main memory. In some scenarios, such as hash consing, common subexpression elimination, or parser lookup tables, the requirement for batching is a dealbreaker: sorting isn’t viable. This is because hash tables use O(unique keys) memory, while radix sort uses O(accesses); fitting into a smaller footprint often yields better memory-system performance.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of hash tables

hash tables

Photo of Hashed sorting

Hashed sorting