Skip to content

lru: in jump-grow copy loop use peek instead get - #23545

Draft
AskAlexSharov wants to merge 3 commits into
alex/cache_len_contention_37from
alex/cache_grow_peek_37
Draft

lru: in jump-grow copy loop use peek instead get#23545
AskAlexSharov wants to merge 3 commits into
alex/cache_len_contention_37from
alex/cache_grow_peek_37

Conversation

@AskAlexSharov

@AskAlexSharov AskAlexSharov commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

The migration copy in maybeGrow runs with resizeMu and every put stripe held, so its cost is a stall for all writers.

Keys() walks oldest-first, so the new generation's recency order comes from insertion order alone. Get additionally moves each entry to the head of the generation being retired — an unlink plus a relink over three random cache lines per entry, for nothing. Peek does the same lookup without the re-link.

Three copy loops: GenericCache, growLRU, tailLRU.

TestGenericCache_GrowCopyMatchesGetBasedCopy pins the equivalence on the production path: it drives a jump-grow cache and a fixed-capacity one through the identical insert/read sequence, stops the moment the first real grow fires, then rebuilds the copy the way the code read before this change (Get) into the geometry the grow chose. Keys, order, and values must match. Reversing the copy order or dropping one entry in maybeGrow both fail it.

Nothing in execution/cache or execution/commitment reads freelru's own Metrics() — the only behavioural difference between Get and Peek — and no LRU here sets a lifetime, so the shared findKey expiry path is inert.

…w copy loop

Keys() already walks oldest-first, so the new generation's recency order
comes from insertion order. Get additionally moves every entry to the head
of the generation being retired -- an unlink plus a relink over three random
cache lines per entry, inside the all-stripe fence.
@AskAlexSharov
AskAlexSharov force-pushed the alex/cache_grow_peek_37 branch from b2a98d8 to 5d470ed Compare August 25, 2026 05:14
@AskAlexSharov
AskAlexSharov changed the base branch from main to alex/cache_len_contention_37 August 25, 2026 05:14
@AskAlexSharov AskAlexSharov changed the title execution/cache, execution/commitment: peek, not get, in the jump-grow copy loop lru: in jump-grow copy loop use peek instead get Aug 25, 2026
@AskAlexSharov
AskAlexSharov force-pushed the alex/cache_grow_peek_37 branch from 5d470ed to 10b4e27 Compare August 25, 2026 06:25
…to HEAD

# Conflicts:
#	execution/cache/generic_cache.go
@AskAlexSharov

Copy link
Copy Markdown
Collaborator Author

Merged the reworked base (#23522) in at 8773d7f5. The base absorbed half of this PR, so the content changed:

  • GenericCache is done there now. Growth moved into shardedLRU, and migrateLocked already reads the retiring shard with Peek — plus it asserts the copy cannot evict. Nothing left for this PR to change on that path.
  • What remains is growLRU.maybeGrow (grow_lru.go) and tailLRU.maybeGrow (branch_cache_tail.go), which still copy whole-cache with Get.
  • TestGenericCache_GrowCopyMatchesGetBasedCopy no longer compiles against the new geometry (curCap/shardCount moved into shardedLRU), so it is retargeted at growLRU, where the copy loop it pins still exists: TestGrowLRU_GrowCopyMatchesGetBasedCopy in code_cache_concurrency_test.go.

./execution/cache and ./execution/commitment pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant