Ask HN: What is new in algorithms and data structures these days?
737 pointsAlgs/DS were my first love in CS. Nowadays, all we hear about is AI/ML. There must be hardware/software improvements coming from or necessitating fundamental Algs/DS research.
Care to share any of the favorite recent results?
Are there big fields still making gains behind all this computing surge?
Comments (211) 45 threads
Show all comments
Showing thread 4 of 45
How Branch Mispredictions don't affect Quicksort (2016) https://arxiv.org/abs/1604.06697
Quicksort is still the algorithm of choice for general purpose internal unstable sort. In modern hardwares, quicksort spends a lot of time recovering from branch misprediction, because quicksort's comparison branches are inherently unpredictable. The problem is severe to the extent that with branchful quicksort, uneven split with more recursion is faster than even split, because it makes branches more predictable! Exact penalty is hardware microarchitecture specific, but one report is 20:80 split being optimal.
So... you should use branchless quicksort! The technique was pioneered by an implementation called BlockQuicksort, but pdqsort (for pattern-defeating quicksort) https://arxiv.org/abs/2106.05123 is also popular. pdqsort incorporates branchless technique and also includes other enhancements.
Designing a Fast, Efficient, Cache-friendly Hash Table, Step by Step (2017) https://abseil.io/blog/20180927-swisstables
Hash table is the workhorse of data structures, and while improvements are possible for specific usage patterns, open addressing with linear probing is still the fastest implementation for general purpose. So called "Swiss Table" combines cache-friendly metadata layout with SIMD-enhanced probing. These two optimizations work well with each other and combination of two is particularly effective.
I'm sad that it's not "pretty darn quicksort"
* for some arbitrary definition of “constant”
Some people throw the word “constant” around quite freely.
Scientific and mathematical advances are notoriously hard to predict. “Constant” is the last word I would use.
One simple model would be spaced in time according to a memoryless stochastic process while having “impact” scores sampled from an exponential distribution.
Of course, one could include more realisticish dynamics to the model, such as network effects and clumping (e.g. from funding priorities and “ideas in the air”.)
I feel like some areas of computer science tend to correlate with deep statistical appreciation more than others.
Speaking of the topic of stochastic behavior in general, it feels to me like (a) randomized algorithms and (b) better statistical simulations have steadily been gaining traction in algorithms and data structures.