Repository navigation
prompt cache: Imprint finds records by key through an index (stacked on #2316) - #2351
Merged
Merged
Conversation
ashhart
force-pushed
the
lead/imprint-keys
branch
from
November 9, 2026 02:16
d596edb to
5ffe0c8
Compare
This was referenced Nov 9, 2026
ashhart
force-pushed
the
lead/imprint-keys
branch
from
November 9, 2026 04:46
5ffe0c8 to
e0074cd
Compare
ashhart
added a commit
that referenced
this pull request
Nov 10, 2026
Figures corrected to the PRs' measured ones (#2699 head runs, #2509, #2633, #2436, #2644, #2593, #2430, #2568), scope fixed (#2253, #2287, #2511, #2569, #2337, #2627, #2351, #2626), unsourced figures dropped (#2181, #2606, #2257's pricing clauses), the shipped #2176, #2565, #2548 and gfx12 silu entries and the first #2625 copy removed, and the #2568 and #2352 entries unwrapped to one line each.
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.
Rebased onto main now that #2316 has landed: these are the two commits.
--learn's Imprint looked records up by key with a linear scan:find,has,touch, andreload's per-record find after another writer appends. This keeps an index from each record's key to its place in the record list, updated wherever the list changes:addappends;removerenumbers the records after the one it took out;reloadswaps in the fresh map;The records, their order, the clock and eviction victims are the same as before.
Timing at 100,000 learned states (Apple M3 Ultra, ReleaseFast, median of 5 fresh processes; the new timing step is
test-startup-states-timing):find,hasandtouchreload's finds after another writer appendedaddthat has to reloadWhat this doesn't change: a request's lookup is still about 0.7 ms warm and 1.7 ms cold at 100K. That's
best, a prefix scan over every record, which a key index can't speed up.remove's index rewrite is I/O. At 1,000 records every call was already under 17 µs, so the gain shows at large stores.Checks:
prompt_imprint_keys_test.zig) check records, order, clock and victims against a model built from the old linear scans, over random sequences of adds, touches, removes, evictions and reloads. They also pass on the old code, and five planted faults each make them fail.prompt_imprint.zigtests pass 17/17, andzig build test-learn-recoverypasses 528/528.zig fmt --checkpasses.