Skip to content

fix(cache): bound every cache and broadcast table, with flags and gauges - #119

Merged
mattmattox merged 3 commits into
mainfrom
claude/bounded-caches
Nov 13, 2026
Merged

mattmattox merged 3 commits into
mainfrom
claude/bounded-caches

Conversation

@mattmattox

Copy link
Copy Markdown
Contributor

What I found, cache by cache:

  • Block cache: there is none.
  • Directory index: not on main yet (it's on the stale-reads branch), so it's not covered here.
  • Inode, extent and negative caches: already fixed-size LRUs. But Go maps keep the room of evicted keys, so the extent cache grew from 5.8 MB when full to 10.9 MB after 40× its size went through it. A bare map shows the same on go1.26.8: 2.4 MB at 10×, 10 MB at 200×. Rebuilding a shard's map after it has evicted as many entries as it holds keeps it at about 6.6 MB.
  • Broadcast peer table: grew without limit. It had one entry per sender UUID and never dropped any, so every remount or forged heartbeat added one. It's now keyed by address and capped. The per-sender sequence map from fix(broadcast): notice lost invalidations and drop caches instead of waiting for the TTL #96 shares the cap.

Measured memory per entry: about 480 B for inodes, 120 B for extents, 40 B for negative entries. These are in API-CONFIG.md.

TestMultiNodeConcurrentCreatesDoNotCollide: #62 already removed the create loop's EIO retry. Its readback still waited through any read error for 15s; now it retries only a missing file or old content.

Tests on .68 (load 40–90):

  • TestCachesStayBounded: fails without the map rebuild.
  • Unit tests with -race, lint and parity: clean.
  • -short integration suite: 123/0.
  • Full-size create test: 2/2.

The lock "hint cache" gauges are always 0, since locks have no hint cache anymore (the docs already say so). I left them alone.

🤖 Generated with Claude Code

mattmattox and others added 3 commits November 13, 2026 15:47
The broadcast peer table kept one entry per sender UUID and never dropped
one, so every remount and every forged heartbeat grew it. Peers are now
kept by address and, like the per-sender sequence tracking, capped at
-broadcast-max-peers (256), dropping the node heard from longest ago.

The inode, extent and negative caches were LRUs of fixed size, but their
Go maps kept the room of evicted keys: the extent cache took 5.8 MB when
full and 10.9 MB after 40 times its size went through it. Each shard now
rebuilds its map after evicting as many entries as it holds.

-cache-inodes, -cache-extents and -cache-negative set the cache sizes,
and /metrics reports each limit plus the broadcast table sizes.

The create-collision readback no longer waits through read errors other
than a missing file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#97's test still used the old AddPeer(uuid, addr) form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattmattox
mattmattox merged commit 632ea5f into main Nov 13, 2026
17 checks passed
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