perf(cache): preserve adaptive LRU during autopin - #815
Merged
Conversation
Automatic history pinning took up to half of the expert RAM budget before the adaptive LRU was sized, allowing learned pins to reduce cache capacity and increase expert I/O on constrained systems. Reserve the affordable no-pin LRU capacity before calculating the automatic pin budget. Keep explicit PIN and PIN_GB settings authoritative, and document the shared RAM policy. Add focused budget regression cases. Verify the change with the complete Linux and Windows suites and a balanced fixed-token Windows replay that improves median throughput by 3.85% while reducing expert I/O by 4.5%.
This was referenced Aug 5, 2026
Merged
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
PINandPIN_GBbehavior unchangedWhy
Automatic history pinning currently claims up to half of the entire expert RAM budget before
cap_for_ram()sizes the adaptive LRU. On memory-constrained systems, the pinned hot store can therefore displace LRU slots even when that produces more misses and expert I/O.The new calculation determines the no-pin LRU capacity, up to the requested cap, reserves the bytes needed for those slots, and gives automatic pinning only the remaining expert budget. Systems with enough RAM retain the existing half-budget plan. Explicit pin settings remain authoritative.
Validation
make -C c test-c: all native C gates passedmake -C c test-python: 281 passed, 19 skippedmake -C c check ARCH=nativeThe replay used the same binary, model, frozen usage history, token sequence, and CPU-only environment for every arm.