[llvm] [ADT] Speed up FoldingSet with Swiss Table (PR #218156)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 22 16:37:16 PDT 2026
MaskRay wrote:
Note: Swiss Table family algorithms may o may not be suitable as they have large code footprints, and they are bad at smaller keys.
When optimizing SmallPtrSet and DenseMap, I've prototyped, measured, and rejected these alternatives
* Verstable (metadata + home-rooted chains). Wins negative-probe and iteration; loses clang self-build — metadata + chain logic inlines into every call site for +4–10% binary. Combined allocation, NOINLINE cold paths, fragment removal all tried; ~+3% instructions / ~+5% size at best.
* Robin Hood. The find-miss early-out depends on knowing each resident's displacement; without stored metadata it requires re-hashing every resident on the probe walk, which costs more than the saved probes. Storing the displacement recovers the early-out but adds a metadata cache line, and the swap-carry on insert is intrinsic — +10–20% insert vs Algorithm R regardless of layout.
* boost::unordered_flat_map. Bad at pointer keys and code size.
https://github.com/llvm/llvm-project/pull/218156
More information about the llvm-commits
mailing list