Skip to content

lru: fastpath before taking resizeMu in maybeGrow - #23546

Closed
AskAlexSharov wants to merge 3 commits into
alex/cache_grow_peek_37from
alex/cache_grow_latch_37
Closed

lru: fastpath before taking resizeMu in maybeGrow#23546
AskAlexSharov wants to merge 3 commits into
alex/cache_grow_peek_37from
alex/cache_grow_latch_37

Conversation

@AskAlexSharov

@AskAlexSharov AskAlexSharov commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #23545.

A full LRU never drops back below curCap. So once the envelope cannot fund the next grow step, the fast-path gate stays armed forever and every later write re-enters maybeGrow, takes the one global resizeMu, fails the same Reserve and returns — a process-wide serialisation point on the cache write path. tailLRU.Add is worse: it pays an all-shard Len() ahead of that call.

Gate on Budget.CanReserve instead: one atomic load, no per-cache state, and bytes a later Close/Clear returns are picked up on the next write with nothing to reset. state_cache.go already documents "that cache stops growing" — now that is what the code does.

Same gate in GenericCache.putStriped, growLRU.Add, tailLRU.Add.

Not what the current stage_exec mutex profile shows (those events are funded grows); this is the cliff behind them.

@AskAlexSharov
AskAlexSharov force-pushed the alex/cache_grow_latch_37 branch from d6aaae4 to 724ce74 Compare August 25, 2026 04:48
@AskAlexSharov AskAlexSharov changed the title common/cachebudget, execution/cache, execution/commitment: latch off a grow the envelope refused common/cachebudget, execution/cache, execution/commitment: skip an unfundable grow before taking resizeMu Aug 25, 2026
@AskAlexSharov
AskAlexSharov force-pushed the alex/cache_grow_latch_37 branch from 724ce74 to b2a98d8 Compare August 25, 2026 05:01
@AskAlexSharov AskAlexSharov reopened this Aug 25, 2026
@AskAlexSharov
AskAlexSharov force-pushed the alex/cache_grow_peek_37 branch from b2a98d8 to 5d470ed Compare August 25, 2026 05:14
@AskAlexSharov
AskAlexSharov force-pushed the alex/cache_grow_latch_37 branch from 105d505 to 75930e9 Compare August 25, 2026 05:14
@AskAlexSharov AskAlexSharov changed the title common/cachebudget, execution/cache, execution/commitment: skip an unfundable grow before taking resizeMu lru: fastpath before taking resizeMu in maybeGrow Aug 25, 2026
…fundable grow before taking resizeMu

A full LRU never drops back below curCap, so once the envelope cannot fund
the next step the fast-path gate stays armed and every later write re-enters
maybeGrow and serialises on the single resizeMu. tailLRU also pays an
all-shard Len() ahead of it. Gate on CanReserve instead, which needs no
per-cache state and picks up bytes a later Close returns on its own.
@AskAlexSharov
AskAlexSharov force-pushed the alex/cache_grow_peek_37 branch from 5d470ed to 10b4e27 Compare August 25, 2026 06:25
@AskAlexSharov
AskAlexSharov force-pushed the alex/cache_grow_latch_37 branch from 0c5cfcc to 717ae7c Compare August 25, 2026 06:25
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