ht: fuse keys/values arrays into a single entries array (fixes #84) - #96
Merged
Merged
Conversation
Replace the separate keys and values backing arrays in ttak_map_t and
ttak_table_t (keys/key_lens/values) with one fused entries array of
{key, value} pairs, keeping ctrls separate so probing logic is unchanged.
A successful lookup now touches at most two cache lines (ctrl byte +
entry) instead of three (ctrl byte + key line + value line).
Tombstone tracking from 80447e7 is preserved: deletes still mark slots
DELETED and bump the tombstone count, inserts reuse the first tombstone
slot on the probe chain and decrement, and rehash-in-place/growth still
clears tombstones by rebuilding from live entries only. The two mem.c
iterations over the global ptr map now read entries[i].key instead of
keys[i]. Public API is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
keys/valuesbacking arrays (andkey_lensfor the generic table) into a single fusedentriesarray of{key, value}pairs in bothttak_map_t(include/ttak/ht/hash.h) andttak_table_t(include/ttak/ht/table.h), keepingctrlsas a separate array so the probing logic is untouched.DELETED+ bumps the tombstone count, insert reuses the first tombstone slot on the probe chain and decrements, and rehash-in-place/growth still clears tombstones by rebuilding from live entries only.src/mem/mem.citerations over the global ptr map readentries[i].keyinstead ofkeys[i].Benchmark
Random lookup throughput on a 1M-entry
tt_map_t(capacity 2^21, ~50% load), 10M random lookups per rep, best-of-9 / median-of-9 reps,clock_gettime(CLOCK_MONOTONIC), same bench binary linked against the pre-change lib (95854ca) and the new lib:~2% better best-case and ~4% better median lookup latency. The absolute numbers are inflated by per-call
ttak_mem_access()overhead in the public map API; the structural cache-miss reduction (3→2 lines per hit) is the intended win and shows up consistently in best-case latency.Full
make testsuite passes on the branch.Not merged — leaving for review.