[llvm] [DenseMap] Replace tombstone deletion with TAOCP 6.4 Algorithm R (PR #199615)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu May 28 06:51:41 PDT 2026


================
@@ -605,37 +624,21 @@ class DenseMapBase : public DebugEpochBase {
                                   BucketT *TheBucket) {
     incrementEpoch();
 
-    // If the load of the hash table is more than 3/4, or if fewer than 1/8 of
-    // the buckets are empty (meaning that many are filled with tombstones),
-    // grow the table.
-    //
-    // The later case is tricky.  For example, if we had one empty bucket with
-    // tons of tombstones, failing lookups (e.g. for insertion) would have to
-    // probe almost the entire table until it found the empty bucket.  If the
-    // table completely filled with tombstones, no lookup would ever succeed,
-    // causing infinite loops in lookup.
+    // Grow the table if the load factor would exceed 3/4 after insertion.
----------------
MaskRay wrote:

Good question. Rather than block this PR on load-factor tuning, I filed #200183 to track it — the size-gated 2/3 idea, and possibly a different table algorithm for non-small `pair<key, value>`. Keeping 3/4 here for now.

https://github.com/llvm/llvm-project/pull/199615


More information about the llvm-commits mailing list