A GROUP BY did 70% more work and finished faster, because it waited less for RAM
Splitting a 99M-row aggregation into 4,096 cache-sized partitions cut DRAM loads from about 76M to about 25.7M.
On ClickBench's hits table, a naive hash map ran in 3.9 s cold with half of CPU slots stalled on memory. Radix partitioning raised instruction counts from 11.4B to 19.4B but ran in 3.3 s cold.
A reader argues this is old news, while another with embedded experience says teams need benchmark numbers before they believe in mechanical sympathy.
A busy CPU that is mostly waiting
The post starts from a latency gap. A core executes roughly 4 to 8 instructions per nanosecond, while a DRAM access takes 50 to 100 ns, so one cache miss costs about 400 to 800 instructions.
On a single pinned core, a naive GROUP BY UserID over 99M rows (about 17M unique users) took 3.9 s cold. Perf showed 50.1% of slots stalled on memory, with about 76M DRAM loads.
| Naive hash map | 4,096 radix partitions | |
|---|---|---|
| Cold run | 3.9 s | 3.3 s |
| Warm run | 3.6 s | 2.7 s |
| Memory-stalled slots | 50.1% | 23.5% |
| DRAM loads | ~76M | ~25.7M |
Partitioning on the top 12 hash bits adds work, from about 11.4B to 19.4B operations, but the stalled slots fall from about 8.4B to 3.8B.
Novel, or a textbook trick?
"Uh, isn't this just radix-partitioned aggregation? Hierarchical (fixed two level) aggregation is old. What's novel here?" — quotemstr
He adds that he doesn't see why the author's project exists when DuckDB and ClickHouse do. The author says the post is the first of a series on prefetching, memory throughput and join probing.
Lost art at work
An embedded engineer described two teams on STM32 chips. One used deep C++ class hierarchies on a core with little cache. He wrote inline-allocating containers and index-based object pools on a part with under a megabyte of RAM, and had to show benchmark numbers to convince the first team he wouldn't be the bottleneck.
Get breakdowns like this every day
The top Hacker News stories, unpacked — by email, Telegram, or RSS.
Prospero is a coding harness in C++ that stays out of the way of your fuzzer
Chris Wellons argues a harness is 'curl glued to popen()' and built one that uses roughly two orders of magnitude fewer resources than web-stack rivals.