diff options
| author | snowstormxd <214507868+snowstormxd@users.noreply.github.com> | 2026-11-02 19:07:54 +0000 |
|---|---|---|
| committer | snowstormxd <214507868+snowstormxd@users.noreply.github.com> | 2026-11-02 19:07:54 +0000 |
| commit | 00285925faebcd9fce6f12b4ebfaccdab491203c (patch) | |
| tree | 77ea4336ab7383b5a1ef202856149343cd0d1a04 /src/common | |
| parent | 226162edf525f13bb0c1fa5c4788e510c474989d (diff) | |
core: skip empty bitmap ranges during cache and scheduler traversal
Adapted bitmap scans from sylvieistaken/selevet-eglantine performance build 4. Keep the wide-priority fallback and fix the first live slot after empty bitmap words. Include randomized lifecycle and ordering checks.
Assisted by Codex.
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/slot_vector.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/common/slot_vector.h b/src/common/slot_vector.h index f6da7a59d1..8e1c06e35a 100644 --- a/src/common/slot_vector.h +++ b/src/common/slot_vector.h @@ -52,12 +52,16 @@ public: const u64* const bitset = slot_vector->stored_bitset.data(); const u32 size = static_cast<u32>(slot_vector->stored_bitset.size()) * 64; if (id.Value() < size) { - do { - ++id.index; - } while (id.Value() < size && !IsValid(bitset)); - if (id.Value() == size) { - id = SlotId{}; + u32 index = id.Value() + 1; + while (index < size) { + const u64 word = bitset[index / 64] >> (index % 64); + if (word != 0) { + index += static_cast<u32>(std::countr_zero(word)); + break; + } + index = (index / 64 + 1) * 64; } + id = index < size ? SlotId{index} : SlotId{}; } return *this; } @@ -139,7 +143,7 @@ public: if (it == stored_bitset.end()) { return end(); } - const u32 word_index = static_cast<u32>(std::distance(it, stored_bitset.begin())); + const u32 word_index = static_cast<u32>(std::distance(stored_bitset.begin(), it)); const SlotId first_id{word_index * 64 + static_cast<u32>(std::countr_zero(*it))}; return Iterator(this, first_id); } |
