Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
3688f3c
CUDA keyed graph cache and device arena, both off until a family inst…
jayleaton Oct 10, 2026
b7be793
A failed CUDA kernel launch names its kernel and launch configuration…
jayleaton Oct 10, 2026
faf5901
fix(cuda): correct RDMA VMM capability attribute
jrb-ai Oct 10, 2026
3cc0397
Graph cache: a capture is freed until the map holds it, the keep floo…
jayleaton Oct 11, 2026
c58d83c
CUDA arena: the address maps are rehashed before tombstones fill them
jayleaton Oct 11, 2026
25c02d3
Tensor parallelism across CUDA processes: bootstrap, NCCL, mailbox an…
jayleaton Oct 10, 2026
6b5404d
TP tests: a drain on rank 0 then its clean stop ends rank 1's loop at…
jayleaton Oct 10, 2026
06c4e75
TP RoCE: with no TF_TP_ROCE_HCA, each rank picks the ports on an IPv4…
jayleaton Oct 11, 2026
062af8b
TP README: when -Dtp-nvcc, TF_TP_ROCE_HCA, NCCL_IB_HCA, NCCL_SOCKET_I…
jayleaton Oct 11, 2026
d7510ef
TP test runner: a binary built without the mailbox kernel refuses the…
jayleaton Oct 11, 2026
e16e331
TP RoCE: every RDMA post is bounds-checked before the verb, and peers…
jayleaton Oct 11, 2026
649e788
TP RoCE: no RDMA write past 1 MiB, and boot refuses any setting that …
jayleaton Oct 11, 2026
664a8e2
TP RoCE: TF_TP_ROCE_CHUNKED_KB gathers strides past the slot in slot-…
jayleaton Oct 11, 2026
4ad5029
TP RoCE: a failed transport halts its QPs, drains them and keeps its …
jayleaton Oct 11, 2026
9bbc21a
TP RoCE: tf-tp-test failfast V transport checks the failed-transport …
jayleaton Oct 11, 2026
cf19042
Fix RoCE test smaps lookup for merged mappings
jayleaton Oct 11, 2026
0ba7d30
Sessions: the page map is rehashed before tombstones fill it
jayleaton Oct 11, 2026
0918809
Let a family's round planner drive the lane host with prompt pieces
jayleaton Oct 10, 2026
361f063
Lane host halt: a stop's drain deadline ends the rounds at the next b…
jayleaton Oct 10, 2026
e9f9210
Round planner test: both prompts queue before the host starts, and it…
jayleaton Oct 10, 2026
96ae865
Server hooks for a model family's own chat rules.
jayleaton Oct 10, 2026
df480e0
Server: a stop logs its signal and the open connections when the acce…
jayleaton Oct 10, 2026
2c4d837
Server: SIGTERM / SIGINT drains before stopping.
jayleaton Oct 10, 2026
55bf0a7
Server tests: a stop that lands between a request's count and its dra…
jayleaton Oct 10, 2026
9fbc2b3
Server: a stream that has not sent its first token gets keepalives ev…
jayleaton Oct 10, 2026
bb53ff4
Server tests: the drain test's reply in progress is held until its dr…
jayleaton Oct 10, 2026
9eb765d
DeepSeek-V4.1 host side: release config, EXL3 pack headers, a rank's …
jayleaton Oct 11, 2026
865335e
DeepSeek-V4.1 weight forms built at load, and prepared weight folders…
jayleaton Oct 11, 2026
b775815
DeepSeek-V4.1 phase timers: where a serving round's time goes, by nam…
jayleaton Oct 11, 2026
989ca7e
TP RoCE: run_hosts.sh gives NCCL the RoCE picker's ports when neither…
jayleaton Oct 11, 2026
05c5213
Session memory for paged-KV families: page pool, prefix trie, RAM res…
jayleaton Oct 10, 2026
a3303c7
CUDA keyed graph cache and device arena, both off until a family inst…
jayleaton Oct 10, 2026
69e8a65
A failed CUDA kernel launch names its kernel and launch configuration…
jayleaton Oct 10, 2026
d7e89df
fix(cuda): correct RDMA VMM capability attribute
jrb-ai Oct 10, 2026
5826f89
Graph cache: a capture is freed until the map holds it, the keep floo…
jayleaton Oct 11, 2026
5806e55
CUDA arena: the address maps are rehashed before tombstones fill them
jayleaton Oct 11, 2026
d335520
Graph cache: TF_GRAPH_CACHE=0 or off runs every step eagerly in any f…
jayleaton Oct 14, 2026
7ff83d8
Tensor parallelism across CUDA processes: bootstrap, NCCL, mailbox an…
jayleaton Oct 10, 2026
9af2ea2
TP tests: a drain on rank 0 then its clean stop ends rank 1's loop at…
jayleaton Oct 10, 2026
7c9a26e
TP RoCE: with no TF_TP_ROCE_HCA, each rank picks the ports on an IPv4…
jayleaton Oct 11, 2026
8ebb0be
TP README: when -Dtp-nvcc, TF_TP_ROCE_HCA, NCCL_IB_HCA, NCCL_SOCKET_I…
jayleaton Oct 11, 2026
e9e0056
TP test runner: a binary built without the mailbox kernel refuses the…
jayleaton Oct 11, 2026
0472cbf
TP RoCE: every RDMA post is bounds-checked before the verb, and peers…
jayleaton Oct 11, 2026
9688398
TP RoCE: no RDMA write past 1 MiB, and boot refuses any setting that …
jayleaton Oct 11, 2026
72132f0
TP RoCE: TF_TP_ROCE_CHUNKED_KB gathers strides past the slot in slot-…
jayleaton Oct 11, 2026
e65583c
Server hooks for a model family's own chat rules.
jayleaton Oct 10, 2026
bf19238
TP RoCE: a failed transport halts its QPs, drains them and keeps its …
jayleaton Oct 11, 2026
9a486bb
Server: a stop logs its signal and the open connections when the acce…
jayleaton Oct 10, 2026
beae7e8
TP RoCE: tf-tp-test failfast V transport checks the failed-transport …
jayleaton Oct 11, 2026
467504a
Server: SIGTERM / SIGINT drains before stopping.
jayleaton Oct 10, 2026
602aad5
Fix RoCE test smaps lookup for merged mappings
jayleaton Oct 11, 2026
23bf7d8
Server tests: a stop that lands between a request's count and its dra…
jayleaton Oct 10, 2026
890dfc6
TP RoCE: run_hosts.sh gives NCCL the RoCE picker's ports when neither…
jayleaton Oct 11, 2026
5410eac
Session memory for paged-KV families: page pool, prefix trie, RAM res…
jayleaton Oct 10, 2026
a5b8b35
Server: a stream that has not sent its first token gets keepalives ev…
jayleaton Oct 10, 2026
a3e2fb1
TP NCCL: all_reduce's doc says NCCL adds in its ring's order, so its …
jayleaton Oct 14, 2026
0d0bdb2
Sessions: the page map is rehashed before tombstones fill it
jayleaton Oct 11, 2026
2b3cccf
Server tests: the drain test's reply in progress is held until its dr…
jayleaton Oct 10, 2026
62a75ae
TP: keep Linux-only transport host tests off macOS builds
jayleaton Oct 15, 2026
2cf61d3
Sessions: honor zero residency budgets and reserve uncapped requests
jayleaton Oct 15, 2026
9367784
server: keep shared halt and drain on the existing template path
jayleaton Oct 15, 2026
864fe25
Graph cache: effective settings have one digest for ranks to compare …
jayleaton Oct 16, 2026
e2504f6
TP: bootstrap compares the graph cache's effective settings, so a ran…
jayleaton Oct 16, 2026
dcdc30c
Keep the Linux NVMe lane test out of portable host tests
cwschroeder Oct 16, 2026
368a0d3
Keep the Linux NVMe lane test out of portable host tests
cwschroeder Oct 16, 2026
7a6b32f
server: main's drain stop closes the engine without the closed lane-h…
jayleaton Oct 16, 2026
abcad7d
Merge ashhart/main into stack/02-graph-cache-arena
jayleaton Oct 16, 2026
02d455e
Merge stack/02-graph-cache-arena (with ashhart/main) into stack/03-tp…
jayleaton Oct 16, 2026
9266f3f
Merge stack/03-tp-fabric (with ashhart/main) into stack/04-sessions
jayleaton Oct 16, 2026
001ac2e
Merge stack/04-sessions (with ashhart/main) into stack/07-server
jayleaton Oct 16, 2026
33c0ef6
Merge stack/07-server (sessions, TP, graph cache, current main) into …
jayleaton Oct 16, 2026
af0bc53
Server tests: the drain test imports the named json module
jayleaton Oct 16, 2026
7051a3c
Merge stack/07-server's drain-test json import fix into stack/08a-config
jayleaton Oct 16, 2026
e6df8ad
merge origin/main: the round planner and halt on main's split lane host
jayleaton Oct 16, 2026
4da2618
Merge shared/lane-host-core (#861, on current main) into stack/08a-co…
jayleaton Oct 16, 2026
8900c7c
Sessions: a failed prefix insert leaves the index as it was
jayleaton Oct 17, 2026
3aeebb9
CUDA arena: a reuse whose address-map insertion fails keeps its range…
jayleaton Oct 17, 2026
46161ac
Merge stack/02-graph-cache-arena (the #635 arena fix) into stack/03-t…
jayleaton Oct 17, 2026
78ce706
Merge stack/03-tp-fabric (the #635 arena and #637 prefix fixes) into …
jayleaton Oct 17, 2026
9c5bd60
Merge stack/04-sessions (the #635 arena and #637 prefix fixes) into s…
jayleaton Oct 17, 2026
eaa7953
Merge stack/07-server (the #635 arena and #637 prefix fixes) into sta…
jayleaton Oct 17, 2026
88418d8
test(tp): reject malformed runner commands before configuration
cwschroeder Oct 17, 2026
4c69b0d
fix(tp): parse runner commands before opening sessions
cwschroeder Oct 17, 2026
4df28ce
test(tp): retain verbs load failures in HCA diagnostics
cwschroeder Oct 17, 2026
0a80da0
fix(tp): distinguish verbs load errors from absent HCA ports
cwschroeder Oct 17, 2026
999cb03
Merge stack/03-tp-fabric (adopted #636 runner CLI validation and HCA …
jayleaton Oct 18, 2026
5f14a64
Merge the layer below (adopted #636 runner CLI validation and HCA ver…
jayleaton Oct 18, 2026
749240a
Merge the layer below (adopted #636 runner CLI validation and HCA ver…
jayleaton Oct 18, 2026
cdde1a4
Merge ashhart/main (1.1.0, 76aafcf2) into stack/02-graph-cache-arena
jayleaton Oct 18, 2026
adbdb8a
CUDA launches: a not-ready launch returns NotReady unlogged, as Drive…
jayleaton Oct 18, 2026
3bd6a6a
Merge stack/02-graph-cache-arena (adbdb8ab, main 76aafcf2) into stack…
jayleaton Oct 18, 2026
54141a1
Merge stack/03-tp-fabric (3bd6a6ab, main 76aafcf2) into stack/04-sess…
jayleaton Oct 18, 2026
80d4ed5
Merge stack/04-sessions (54141a1e, main 76aafcf2) into stack/07-server
jayleaton Oct 18, 2026
aebceae
Merge stack/07-server (80d4ed5c, main 76aafcf2) into stack/08a-config
jayleaton Oct 18, 2026
1003f08
Build: DeepSeek-V4.1's host tests on hosts other than Windows, whose …
jayleaton Oct 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Graph cache: a capture is freed until the map holds it, the keep floo…
…r stays under the max, a max of 0 is eager

- A capture whose agreement throws, or whose insert runs out of memory, no longer leaks its executable: the map's
  slot is reserved before the capture, and the executable is owned here until the insert, which cannot fail.
- A host map that cannot grow counts as no room in the existing room vote, so every rank declines that miss together.
- `min_keep` is clamped to `max`, so under the memory floor the cap never rises above the configured max. A max of 0
  runs every step eagerly, with no collective.
- A cap lowered to 0 under the floor goes back to max once every rank has room, instead of staying eager for good.
- Hits make no collective: with `Agree` set, keys, settings and fingerprint changes must already match on every rank.
  The docs now say so: the fingerprint changes at the same step on every rank, and `fingerprintOf` is for one rank.

Co-authored-by: Jonathan Regan-Beasley <197533392+jregan-beasley-smc@users.noreply.github.com>
  • Loading branch information
jayleaton committed Oct 11, 2026
commit 3cc0397482e01bbf88f3dcfbbded98725e0eeca1
31 changes: 20 additions & 11 deletions zig/src/cuda/graph_cache.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub const Body = struct {
run: *const fn (ctx: *anyopaque, stream: Stream) anyerror!void,
};

/// Every rank's verdict AND-ed, so ranks capture, evict and fall back at the same steps; never called in a capture.
/// Every rank's verdict AND-ed on a miss (hits never call it), so ranks capture, evict and fall back together.
pub const Agree = struct {
ctx: *anyopaque,
all: *const fn (ctx: *anyopaque, ok: bool) anyerror!bool,
Expand Down Expand Up @@ -53,7 +53,9 @@ pub fn Cache(comptime Key: type) type {
stats: struct { replayed: u64 = 0, captured: u64 = 0, eager: u64 = 0, evicted: u64 = 0, dropped: u64 = 0, floor_hits: u64 = 0 } = .{},

pub fn init(gpa: std.mem.Allocator, engine: Engine, settings: Settings) Self {
return .{ .gpa = gpa, .engine = engine, .settings = settings, .cap = settings.max };
var s = settings;
s.min_keep = @min(s.min_keep, s.max); // the floor never holds more than the configured max
return .{ .gpa = gpa, .engine = engine, .settings = s, .cap = s.max };
}

pub fn deinit(c: *Self) void {
Expand Down Expand Up @@ -98,9 +100,9 @@ pub fn Cache(comptime Key: type) type {
return .eager;
}

/// One step: the key's graph launched, captured first on a miss; a new `fingerprint` drops every graph first.
/// One step: the key's graph, captured first on a miss; a new `fingerprint` (same step on all ranks) drops all.
pub fn run(c: *Self, key: Key, stream: Stream, fingerprint: u64, body: Body) !Outcome {
if (!c.settings.on or c.failed) return c.eager(stream, body);
if (!c.settings.on or c.failed or c.settings.max == 0) return c.eager(stream, body);
if (c.fingerprint != null and c.fingerprint.? != fingerprint) c.dropAll();
c.fingerprint = fingerprint;
c.tick += 1;
Expand All @@ -110,9 +112,10 @@ pub fn Cache(comptime Key: type) type {
c.stats.replayed += 1;
return .replayed;
}
// a miss: room on every rank, else shed the least recent quarter and lower the cap (once below it, eager)
const room_here = if (c.room) |f| f() else true;
if (!try c.agreed(room_here and c.cap > 0)) {
// a miss: room on every rank (a host map that cannot grow is none), else shed a quarter and lower the cap
const reserved = if (c.entries.ensureUnusedCapacity(c.gpa, 1)) |_| true else |_| false;
const room_here = reserved and (if (c.room) |f| f() else true);
if (!try c.agreed(room_here)) {
if (c.settings.hold) {
if (!quiet and c.stats.floor_hits == 0) std.log.warn("graph cache: under the memory floor on {s} rank: this key eager, {d} graphs held (hold)", .{ if (room_here) "another" else "this", c.entries.count() });
c.stats.floor_hits += 1;
Expand All @@ -123,7 +126,7 @@ pub fn Cache(comptime Key: type) type {
for (0..drop) |_| if (c.entries.count() > c.settings.min_keep) c.evictOldest();
}
const was = c.cap;
c.cap = @intCast(@max(c.entries.count(), c.settings.min_keep));
c.cap = @intCast(@max(c.entries.count(), c.settings.min_keep)); // min_keep <= max (init)
c.stats.floor_hits += 1;
if (!quiet and c.cap != was) std.log.warn("graph cache: under the memory floor on {s} rank: cap {d} -> {d} ({d} held, {d} evicted, {d} eager so far)", .{ if (room_here) "another" else "this", was, c.cap, c.entries.count(), c.stats.evicted, c.stats.eager + 1 });
return c.eager(stream, body);
Expand All @@ -138,13 +141,15 @@ pub fn Cache(comptime Key: type) type {
if (!quiet) std.log.warn("graph capture failed: {s} (key {any}, {d} graphs held)", .{ @errorName(err), key, c.entries.count() });
break :blk null;
};
var owned = exec; // freed here until the map holds it, so a failed agreement cannot leak it
defer if (owned) |x| c.engine.free(c.engine.ctx, x);
if (!try c.agreed(exec != null)) {
if (exec) |x| c.engine.free(c.engine.ctx, x);
c.failed = true;
c.dropAll();
return c.eager(stream, body);
}
try c.entries.put(c.gpa, key, .{ .exec = exec.?, .used = c.tick });
c.entries.putAssumeCapacityNoClobber(key, .{ .exec = exec.?, .used = c.tick });
owned = null;
try c.engine.launch(c.engine.ctx, exec.?, stream);
c.stats.captured += 1;
return .captured;
Expand Down Expand Up @@ -196,7 +201,7 @@ pub const CudaEngine = struct {
}
};

/// FNV-1a over the addresses a body captures (buffer bases, sizes): the fingerprint `run` compares.
/// FNV-1a over the addresses a body captures (buffer bases, sizes): the fingerprint `run` compares, on one rank only.
pub fn fingerprintOf(words: []const u64) u64 {
var h: u64 = 0xcbf29ce484222325;
for (words) |w| {
Expand Down Expand Up @@ -390,3 +395,7 @@ test "graph cache: off runs every step eagerly" {
test "graph cache: fingerprint" {
try std.testing.expect(fingerprintOf(&.{ 1, 2 }) != fingerprintOf(&.{ 2, 1 }));
}

test {
_ = @import("graph_cache_regression_test.zig");
}
181 changes: 181 additions & 0 deletions zig/src/cuda/graph_cache_regression_test.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
//! Failure ownership, rank verdict counts and bounded-cap regressions for the graph cache.

const std = @import("std");
const cache = @import("graph_cache.zig");
const Stream = @import("stream.zig").Stream;
const no_stream: Stream = .{ .d = undefined, .handle = null };
const expect = std.testing.expect;
const equal = std.testing.expectEqual;

const Engine = struct {
captures: usize = 0,
live: usize = 0,
launches: usize = 0,
bodies: usize = 0,
handles: [32]u8 = undefined,

fn engine(e: *Engine) cache.Engine {
return .{ .ctx = e, .capture = capture, .launch = launch, .free = free };
}
fn capture(p: *anyopaque, _: Stream, _: cache.Body) !*anyopaque {
const e: *Engine = @ptrCast(@alignCast(p));
e.captures += 1;
e.live += 1;
return &e.handles[e.captures % e.handles.len];
}
fn launch(p: *anyopaque, _: *anyopaque, _: Stream) !void {
const e: *Engine = @ptrCast(@alignCast(p));
e.launches += 1;
}
fn free(p: *anyopaque, _: *anyopaque) void {
const e: *Engine = @ptrCast(@alignCast(p));
std.debug.assert(e.live > 0);
e.live -= 1;
}
fn body(e: *Engine) cache.Body {
return .{ .ctx = e, .run = run };
}
fn run(p: *anyopaque, _: Stream) !void {
const e: *Engine = @ptrCast(@alignCast(p));
e.bodies += 1;
}
};

const Peer = struct {
verdicts: []const bool,
at: usize = 0,
throw_at: ?usize = null,
fn agree(p: *Peer) cache.Agree {
return .{ .ctx = p, .all = all };
}
fn all(ctx: *anyopaque, ok: bool) !bool {
const p: *Peer = @ptrCast(@alignCast(ctx));
const at = p.at;
p.at += 1;
if (p.throw_at == at) return error.CollectiveFailed;
if (at >= p.verdicts.len) return error.UnexpectedCollective;
return ok and p.verdicts[at];
}
};

test "graph cache regression: capture agreement throw frees the not-yet-inserted executable" {
var e: Engine = .{};
// per miss: room, then the capture's verdict
var p: Peer = .{ .verdicts = &.{ true, true }, .throw_at = 1 };
var c = cache.Cache(u32).init(std.testing.allocator, e.engine(), .{});
defer c.deinit();
c.agree = p.agree();
try std.testing.expectError(error.CollectiveFailed, c.run(1, no_stream, 7, e.body()));
try equal(@as(usize, 1), e.captures);
try equal(@as(usize, 0), e.live);
try equal(@as(usize, 0), c.count());
try equal(@as(usize, 2), p.at);
}

test "graph cache regression: local map OOM declines before any capture and can recover" {
var e: Engine = .{};
var failing = std.testing.FailingAllocator.init(std.testing.allocator, .{ .fail_index = 0 });
var c = cache.Cache(u32).init(failing.allocator(), e.engine(), .{});
defer c.deinit();
try equal(cache.Outcome.eager, try c.run(1, no_stream, 7, e.body()));
try expect(failing.has_induced_failure);
try equal(@as(usize, 0), e.captures);
try equal(@as(usize, 0), e.live);
try expect(!c.failed);
failing.fail_index = std.math.maxInt(usize);
try equal(cache.Outcome.captured, try c.run(1, no_stream, 7, e.body()));
try equal(@as(usize, 1), e.live);
}

test "graph cache regression: peer map OOM makes a locally prepared rank eager before capture" {
var e: Engine = .{};
var p: Peer = .{ .verdicts = &.{false} };
var c = cache.Cache(u32).init(std.testing.allocator, e.engine(), .{});
defer c.deinit();
c.agree = p.agree();
try equal(cache.Outcome.eager, try c.run(1, no_stream, 7, e.body()));
try equal(@as(usize, 1), p.at);
try equal(@as(usize, 0), e.captures);
try equal(@as(usize, 1), e.bodies);
}

test "graph cache regression: local OOM still contributes the room verdict" {
var e: Engine = .{};
var failing = std.testing.FailingAllocator.init(std.testing.allocator, .{ .fail_index = 0 });
var p: Peer = .{ .verdicts = &.{true} };
var c = cache.Cache(u32).init(failing.allocator(), e.engine(), .{});
defer c.deinit();
c.agree = p.agree();
try equal(cache.Outcome.eager, try c.run(1, no_stream, 7, e.body()));
try equal(@as(usize, 1), p.at);
try equal(@as(usize, 0), e.captures);
}

test "graph cache regression: hits make no collective; a fingerprint change shared by every rank recaptures" {
var e: Engine = .{};
var p: Peer = .{ .verdicts = &.{ true, true, true, true, true, true } };
var c = cache.Cache(u32).init(std.testing.allocator, e.engine(), .{});
defer c.deinit();
c.agree = p.agree();
_ = try c.run(1, no_stream, 7, e.body());
_ = try c.run(2, no_stream, 7, e.body());
try equal(@as(usize, 4), p.at);
for (0..4) |_| try equal(cache.Outcome.replayed, try c.run(1, no_stream, 7, e.body()));
try equal(@as(usize, 4), p.at);
// a new layout generation on every rank: both graphs go, the next miss agrees twice as any other
try equal(cache.Outcome.captured, try c.run(1, no_stream, 8, e.body()));
try equal(@as(usize, 6), p.at);
try equal(@as(u64, 2), c.stats.dropped);
try equal(@as(usize, 1), c.count());
try equal(@as(usize, 1), e.live);
}

var room = true;
fn available() bool {
return room;
}

test "graph cache regression: zero maximum remains eager across pressure recovery, with no collective" {
var e: Engine = .{};
var p: Peer = .{ .verdicts = &.{} };
var c = cache.Cache(u32).init(std.testing.allocator, e.engine(), .{ .max = 0 });
defer c.deinit();
c.room = available;
c.agree = p.agree();
for ([_]bool{ false, true, false, true }) |ok| {
room = ok;
try equal(cache.Outcome.eager, try c.run(1, no_stream, 7, e.body()));
try equal(@as(u32, 0), c.cap);
try equal(@as(usize, 0), c.count());
}
try equal(@as(usize, 0), e.captures);
try equal(@as(usize, 0), p.at);
}

test "graph cache regression: default floor cannot enlarge a two-entry maximum" {
var e: Engine = .{};
var c = cache.Cache(u32).init(std.testing.allocator, e.engine(), .{ .max = 2 });
defer c.deinit();
c.room = available;
try equal(@as(u32, 2), c.settings.min_keep);
room = false;
_ = try c.run(1, no_stream, 7, e.body());
room = true;
for (0..8) |key| {
_ = try c.run(@intCast(key), no_stream, 7, e.body());
try expect(c.count() <= 2 and c.cap <= 2 and e.live <= 2);
}
}

test "graph cache regression: zero keep floor recovers after reducing the cap to zero" {
var e: Engine = .{};
var c = cache.Cache(u32).init(std.testing.allocator, e.engine(), .{ .max = 2, .min_keep = 0 });
defer c.deinit();
c.room = available;
room = false;
try equal(cache.Outcome.eager, try c.run(1, no_stream, 7, e.body()));
try equal(@as(u32, 0), c.cap);
room = true;
try equal(cache.Outcome.captured, try c.run(1, no_stream, 7, e.body()));
try equal(@as(u32, 2), c.cap);
}