by reconditerose · 2w ago · 0 comments
At this point have we optimized hardware to assume B trees in a sort of self-fulfilling prophesy?
On a cold cache, you pay for each level of indirection, so you want to increase fan-out as much as possible. B-trees do that intrinsically.
I’m not convinced that dedicating 4GB to each processor isn’t the better solution. But it’s a chicken and egg because who would code to it? I think Rust could manage it via the borrow checker, but everyone else would be toast.
They just std::map and AoS and dynamic dispatch everywhere and then grumble "100% CPU usage" when troubleshooting performance problems with top. They might reach for a profiler once all hope is lost, but wouldn't know what to make of performance counters if I showed them some. People who have mechanical sympathy are the exception, not the norm.
Now, if I were to design a NUMA-aware programming model, I would probably expose paired processors and memory pools. Then, create threads assigned to processors and hand them an allocator, like how Zig manages memory allocations.
Sadly, a global heap (malloc/new) and nothing else is standard and that's one of the many, many legacies of 1970s Unix and POSIX we might not be able to get rid of... Most code nowadays either uses it directly or has bespoke hoops to let the user supply a different heap.
The PR for the article. I'm not convinced it's AI, but I didn't do a deep dive on the commit tree just poked around a bit.