[all-commits] [llvm/llvm-project] 1e3dc6: [DenseMap] Store occupancy in a packed used-bit ar...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Jun 4 18:11:46 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1e3dc606df3aefc924fb58238dd705b8bfde1581
      https://github.com/llvm/llvm-project/commit/1e3dc606df3aefc924fb58238dd705b8bfde1581
  Author: Fangrui Song <i at maskray.me>
  Date:   2026-06-04 (Thu, 04 Jun 2026)

  Changed paths:
    M llvm/docs/ProgrammersManual.rst
    M llvm/include/llvm/ADT/DenseMap.h
    M llvm/unittests/ADT/BitVectorTest.cpp
    M llvm/unittests/ADT/DenseMapTest.cpp

  Log Message:
  -----------
  [DenseMap] Store occupancy in a packed used-bit array (#201281)

Track bucket occupancy in a packed 1-bit-per-bucket "used" array (uint32
words)
instead of an `Empty` sentinel key. The buckets and the used array share
one
allocation. The probing scheme is unchanged.
(uint64_t words lead to slightly larger clang binary.)

Because occupancy is a packed bit instead of an in-band sentinel,
probing and
iteration test a dense bit rather than loading each bucket key. This
helps
find-miss and iteration (the empty terminus and the empty buckets become
a bit
test, not a bucket load; for large keys it also skips the structural
compare
against the empty key) and large-bucket insert. It costs find-hit (the
matched
bucket is loaded either way, so the bit is pure overhead) and, for small
buckets,
fill/insert (the per-insert used-bit write). instructions:u rises
slightly
(stage2 sqlite around +0.4% -O0-g), but wall time is neutral-to-faster:
the
find-miss and iteration gains are cache effects an instruction count
does not
see.

The instruction-count increase concentrates in hot (pointer key,
sizeof(bucket) <= 16) maps.

getMemorySize now also counts the used array; the InitSize tests are
updated and
the BitVectorTest DenseSet test no longer expects inserting a default
key to
abort.

Aided by Clause Opus 4.8



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list