Skip to content

Extend memory_limit to the remaining caches - #7966

Draft
dangell7 wants to merge 2 commits into
dangell7/memory-fixfrom
dangell7/memory-pressure
Draft

Extend memory_limit to the remaining caches#7966
dangell7 wants to merge 2 commits into
dangell7/memory-fixfrom
dangell7/memory-pressure

Conversation

@dangell7

@dangell7 dangell7 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

Stacked on #7965; merges after it.

Extends the [memory_limit] budget to the caches that #7965 left on sweep-only sizing: the NodeStore object cache, the ledger cache, the cached SLEs, and fetch packs.

Context of Change

TaggedCache gains an opt-in byte budget: a bytes value and a cost function charge each entry while it is strongly cached, and growth past the budget evicts through the same path as the entry cap. The charges stay correct through inserts, revivals, replacements, deletion, eviction, and the multi-threaded sweep.

Where each cache landed:

  1. The NodeStore object cache is bounded by exact bytes (the serialized blob size plus per-entry overhead), defaulting to an eighth of the budget through a new [node_db] cache_bytes key. Its resident size and bytes are reported in get_counts next to the existing node byte counters.
  2. The ledger cache is bounded by count, since a ledger's byte cost is not well defined: its nodes are shared copy-on-write across neighboring ledgers.
  3. The cached SLEs get a budget-scaled target and cap (this cache previously had no size target), and fetch packs get their existing target as a cap. This also fixes the cached-SLE fetch path, which was not counting its insertions.
  4. RSS acts as a circuit breaker rather than a control loop, since allocator retention means RSS lags eviction. When it stays above 150% of the budget after malloc_trim, sweeps accelerate to every 10 seconds with a warning, and it resets below 130%.

API Impact

  • libxrpl change: TaggedCache gains a ByteBudget constructor parameter and getCacheBytes(); new [node_db] key cache_bytes; admin get_counts adds node_cache_size and node_cache_bytes.

Test Plan

GTest covers the byte budget holding through a burst of exactly-costed values with the sweep unable to fire, alongside the entry-cap and cap-disabled cases. Config, TaggedCache, SHAMapStore, and GetCounts suites pass. Draft until the perf-net soak confirms RSS stays under the budget while load climbs.

@dangell7
dangell7 changed the base branch from develop to dangell7/memory-fix August 6, 2026 17:00
@dangell7 dangell7 changed the title Bound the remaining advisory caches within the memory budget Extend memory_limit to the remaining caches Aug 6, 2026
@dangell7
dangell7 force-pushed the dangell7/memory-pressure branch from b7011af to 36a6599 Compare August 6, 2026 19:18
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