Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
0375746
feat(run-engine): concurrency-key virtual-time key builders
1stvamp Jul 23, 2026
91fb435
feat(run-engine): ckVirtualTimeScheduling options flag
1stvamp Jul 23, 2026
3591bea
feat(run-engine): two-pass virtual-time CK dequeue command
1stvamp Jul 24, 2026
113904f
feat(run-engine): register CK variants in vtime index on enqueue
1stvamp Jul 24, 2026
1765b77
feat(run-engine): re-register CK variants in vtime index on nack
1stvamp Jul 24, 2026
f646766
test(run-engine): fairness scenarios on the real batched dequeue path
1stvamp Jul 24, 2026
9dac71b
test(run-engine): multi-consumer correctness + op-count budget
1stvamp Jul 24, 2026
24b6220
test(run-engine): default-off regression proof
1stvamp Jul 24, 2026
bddc82e
feat(run-engine,webapp): wire ckVirtualTimeScheduling env flag (code-…
1stvamp Jul 24, 2026
86977ff
chore(run-engine): ship note + comment/format cleanup
1stvamp Jul 24, 2026
2b1c389
fix(run-engine,webapp): address whole-branch adversarial review
1stvamp Jul 24, 2026
5cb0aa5
docs(run-engine): record CK vtime known limitations for GA decision
1stvamp Jul 24, 2026
e9da64c
docs(run-engine): plan + references for virtual-time CK fair scheduling
1stvamp Jul 23, 2026
dce0b72
docs(run-engine): add fairness explainer diagrams
1stvamp Jul 24, 2026
21211ae
fix(run-engine): move design docs out of the Mintlify docs/ tree; format
1stvamp Jul 24, 2026
e1444eb
docs(run-engine): tighten CK fairness server-changes note
1stvamp Jul 24, 2026
dea03c6
docs(run-engine): fix stale references in the CK fairness design docs
1stvamp Jul 26, 2026
c804278
docs(run-engine): add CK virtual-time A/B benchmark plan and harness
1stvamp Jul 27, 2026
da3c8fb
docs(run-engine): make the e2e bench harness work on self-hosted
1stvamp Jul 27, 2026
4994295
docs(run-engine): add CK virtual-time benchmark results
1stvamp Jul 27, 2026
3dd789f
chore(run-engine): gitignore benchmark output artifacts
1stvamp Jul 27, 2026
31606d3
docs(run-engine): benchmark Redis CPU and memory vs concurrency-key c…
1stvamp Jul 28, 2026
9015810
chore(run-engine): drop benchmark, e2e, and design docs from the branch
1stvamp Jul 28, 2026
bb07b0b
fix(run-engine): stop an unservable variant pinning the ck virtual-ti…
1stvamp Jul 31, 2026
819e021
fix(run-engine): advance the ck virtual-time floor from servable vari…
1stvamp Jul 31, 2026
b932442
fix(run-engine): keep unservable ck variants in the fair order
1stvamp Jul 31, 2026
d8c5201
fix(run-engine): make ck vtime pass 2 discover unregistered variants
1stvamp Aug 3, 2026
f538f8d
test(run-engine): bound the ckManyKeys first-serve claim
1stvamp Aug 3, 2026
5cd0c65
test(run-engine): pin the ck vtime window-freeze and stranded-entry b…
1stvamp Aug 6, 2026
c2fd2be
docs(run-engine): note the ck vtime retry-storm fallback in the relea…
1stvamp Aug 6, 2026
3298ee2
fix(run-engine): stop unready ck variants blocking the fair pass, and…
1stvamp Aug 15, 2026
6ce9d2a
fix(run-engine): guard the wildcard cleanup in the ck vtime scripts
1stvamp Aug 15, 2026
701d164
fix(run-engine): register a gated ck variant so it can rejoin the fai…
1stvamp Aug 16, 2026
d21cbb9
fix(run-engine): drop drained ck variants from the fair order on ack,…
1stvamp Aug 17, 2026
af407f5
fix(run-engine): remember a drained ck variant's virtual time
1stvamp Aug 18, 2026
50351eb
fix(run-engine): bound the ck idle set by rank, not just by floor
1stvamp Aug 18, 2026
dca1e9c
perf(run-engine): cut two Redis calls from the ck vtime registration …
1stvamp Aug 19, 2026
2b6bfee
perf(run-engine): stop re-registering ck variants already in the fair…
1stvamp Aug 19, 2026
f5c1d74
fix(run-engine): keep the ck vtime floor alive alongside the tags it …
1stvamp Aug 19, 2026
d018b28
docs(run-engine): cut the ck fair scheduling release note down to the…
1stvamp Aug 19, 2026
c11b5c8
fix(run-engine): register a brand-new ck variant behind the pack, not…
1stvamp Aug 20, 2026
bb4d67d
test(run-engine): pin the fresh-key fix and isolate the ck idle rank cap
1stvamp Aug 20, 2026
f3ad8d6
fix(run-engine): stop the ck arrival cap from being reachable
1stvamp Aug 20, 2026
64b2fc9
fix(run-engine): stop concurrency-gated ck variants eating the fair pass
1stvamp Aug 21, 2026
e8aa263
test(run-engine): cover the future-head window guard a mutation audit…
1stvamp Aug 21, 2026
18e6dce
test(run-engine): pin the ck vtime credit round trip and TTL registra…
1stvamp Aug 21, 2026
0a9998d
fix(run-engine): stop the gated ck batch rewinding a live virtual-tim…
1stvamp Aug 21, 2026
2b7a533
test(run-engine): pin the parked tag a gated variant registers with
1stvamp Aug 21, 2026
88127be
docs(run-engine): cut the ck vtime comments back to what the code can…
1stvamp Aug 21, 2026
3c23a3a
fix(run-engine): re-register the TTL entry when the vtime dequeue exp…
1stvamp Aug 21, 2026
e69f000
fix(run-engine): keep parked ck credit when pass 2 repairs a variant
1stvamp Sep 7, 2026
a5fa891
refactor(run-engine): share one copy of the ck ack, nack and dead-let…
1stvamp Sep 15, 2026
838896a
fix(run-engine): restore the snapshotRoute read in the vtime TTL sweep
1stvamp Sep 15, 2026
0584290
refactor(run-engine): share one copy of the remaining ck lua
1stvamp Sep 15, 2026
c5c6bc9
fix(run-engine): make a mistyped ck lua slot a compile error
1stvamp Sep 15, 2026
c8872e2
test(run-engine): pin the snapshotRoute the vtime TTL sweep hands the…
1stvamp Sep 15, 2026
43d0722
test(run-engine): load every run-queue script into redis
1stvamp Sep 15, 2026
565ad2c
merge: integrate origin/main into ck virtual-time scheduling
1stvamp Sep 18, 2026
c4b657d
test(run-engine): thread groupConcurrencyKey into the two direct-Lua …
1stvamp Sep 19, 2026
c4af9aa
docs(run-engine): correct the ckExpireTtlLua sharing comment
1stvamp Sep 19, 2026
b02f4f0
feat(run-engine): warn when ck vtime and queue-gates are both enabled
1stvamp Sep 19, 2026
a9a14be
feat(run-engine): enforce queue-gates in the vtime dequeue and TTL sweep
1stvamp Sep 19, 2026
9040133
feat(webapp): allow a fractional ck vtime quantum
1stvamp Sep 19, 2026
fab8175
fix(run-engine): reject a non-finite ck vtime quantum
1stvamp Sep 20, 2026
027415b
Merge remote-tracking branch 'origin/main' into feat/ck-virtual-time-…
1stvamp Sep 22, 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
test(run-engine): pin the fresh-key fix and isolate the ck idle rank cap
Two tests, both for holes the fresh-key work opened or exposed.

The first pins the fix itself: a persistent backlog against eight brand-new
concurrency keys per call, asserting it keeps pace with the flag-off arm and that
the floor actually moves. Before the fix that shape served the backlog 1 time in
600 against flag-off's 120, so the assertion is nowhere near the boundary.

The second covers the rank cap, which had quietly lost its only test. The idle set
has two bounds, the at-or-below-floor reap and the cap, and the reap was dead while
the floor sat pinned, so the existing test asserted a pinned floor to prove the cap
was doing the work. Unpinning the floor killed that premise: the test now asserts
the floor advances, which is the fix, and no longer says anything about the cap.
The cap still matters, because a park only ever writes a tag ABOVE the floor, so
anything parked faster than the floor climbs is out of the reap's reach. The new
test seeds the idle set directly, far clear of any floor the fixture can reach, so
the reap provably cannot be what trims it, and checks the survivors are the highest
tags rather than an arbitrary subset. Mutation-checked: raising the configured cap
while holding the assertions fixed fails it, so it is not vacuous.
  • Loading branch information
1stvamp committed Sep 18, 2026
commit bb4d67de733af6e4433f2c2779af89ffbaafce59
Original file line number Diff line number Diff line change
Expand Up @@ -453,4 +453,133 @@ describe("CK vtime starvation by drain-and-re-register", () => {
}
}
);
// The idle set has two bounds: the at-or-below-floor score reap, and a hard rank cap.
// The reap does the visible work now that the floor advances, which left the cap with no
// test isolating it. It still matters, because a park only ever writes a tag ABOVE the
// floor, so anything parked faster than the floor climbs is untouchable by the reap and
// the cap is the only thing standing between that and unbounded growth. Seed the set
// directly, well clear of the floor, so the reap provably cannot be what trims it.
redisTest("the rank cap trims the idle set from the bottom", async ({ redisContainer }) => {
const CAP = 10;
const SEEDED = 200;
const keyPrefix = `runqueue:test:rankcap:`;
const queue = createQueue(redisContainer, keyPrefix, true, CAP);

try {
const env = { ...baseEnv, maximumConcurrencyLimit: 20 };
await queue.updateEnvConcurrencyLimits(env);
const shard = testOptions.keys.masterQueueShardForEnvironment(env.id, 2);

// One ordinary servable variant, so the dequeue actually serves and the persist
// block that carries the trim runs at all.
await queue.enqueueMessage({
env,
message: makeMessage({ runId: "r-live", concurrencyKey: "live" }),
workerQueue: env.id,
skipDequeueProcessing: true,
});

const idleKey = testOptions.keys.ckVtimeIdleKeyFromQueue(variantName("live"));
const floorKey = testOptions.keys.ckVtimeFloorKeyFromQueue(variantName("live"));

// Scores from 1000 up, far above any floor this fixture can reach, so
// ZREMRANGEBYSCORE -inf floor matches none of them.
const seed: (string | number)[] = [];
for (let i = 0; i < SEEDED; i++) seed.push(1000 + i, `${variantName("live")}-ghost-${i}`);
await queue.redis.zadd(idleKey, ...(seed as [number, string]));
expect(await queue.redis.zcard(idleKey)).toBe(SEEDED);

const served = await queue.testDequeueFromMasterQueue(shard, env.id, 5);
expect(served.length).toBe(1);

const floor = Number((await queue.redis.get(floorKey)) ?? "0");
const after = await queue.redis.zcard(idleKey);

// The floor never reached the seeded scores, so the reap cannot explain the trim.
expect(floor).toBeLessThan(1000);
expect(after).toBeLessThanOrEqual(CAP + 1);
expect(after).toBeGreaterThan(0);

// Trimmed from the bottom: the survivors are the highest tags, which are the ones
// holding the most remembered credit and so the most expensive to forget.
const survivors = await queue.redis.zrange(idleKey, 0, -1, "WITHSCORES");
const lowest = Number(survivors[1]);
expect(lowest).toBeGreaterThanOrEqual(1000 + SEEDED - (CAP + 1));
} finally {
await queue.quit();
}
});
// The defect Devin reported: a workload minting a previously-unseen concurrency key per
// run pinned the floor at the epoch, so a variant that had ever been served sat above
// every arrival and lost forever. Being served once was a permanent penalty. Measured at
// 1/600 before the fix against flag-off's 120/600.
redisTest(
"a persistent backlog survives a flood of brand-new keys",
async ({ redisContainer }) => {
const CALLS = 120;
const MAX = 5;
const FRESH_PER_CALL = 8; // above MAX on purpose: the overload case

async function run(vtime: boolean) {
const keyPrefix = `runqueue:test:freshflood:${vtime ? "on" : "off"}:`;
const queue = createQueue(redisContainer, keyPrefix, vtime);
try {
const env = { ...baseEnv, maximumConcurrencyLimit: 50 };
await queue.updateEnvConcurrencyLimits(env);
const shard = testOptions.keys.masterQueueShardForEnvironment(env.id, 2);
const t0 = Date.now() - 10_000_000;

for (let i = 0; i < 400; i++) {
await queue.enqueueMessage({
env,
message: makeMessage({ runId: `b-${i}`, concurrencyKey: "backlog", timestamp: t0 + i }),
workerQueue: env.id,
skipDequeueProcessing: true,
});
}

let fresh = 0;
let backlogServed = 0;
for (let call = 0; call < CALLS; call++) {
for (let f = 0; f < FRESH_PER_CALL; f++, fresh++) {
await queue.enqueueMessage({
env,
message: makeMessage({
runId: `f-${fresh}`,
concurrencyKey: `fresh-${fresh}`,
timestamp: t0 + 5_000_000 + fresh,
}),
workerQueue: env.id,
skipDequeueProcessing: true,
});
}
for (const m of await queue.testDequeueFromMasterQueue(shard, env.id, MAX)) {
if (m.message.concurrencyKey === "backlog") backlogServed++;
await queue.acknowledgeMessage(env.organization.id, m.messageId, {
skipDequeueProcessing: true,
});
}
}
const floor = Number(
(await queue.redis.get(testOptions.keys.ckVtimeFloorKeyFromQueue(variantName("backlog")))) ?? "0"
);
return { backlogServed, floor };
} finally {
await queue.quit();
}
}

const on = await run(true);
const off = await run(false);

// Flag off is pure age order, so the always-oldest backlog wins a slot every call.
expect(off.backlogServed).toBeGreaterThanOrEqual(100);
// Flag on now keeps pace with it. Pre-fix this was 1.
expect(on.backlogServed).toBeGreaterThanOrEqual(100);
// And the floor moves, which is the actual repair: arrivals no longer enter at the
// epoch, so virtual time tracks service instead of standing still.
expect(on.floor).toBeGreaterThan(0);
},
120_000
);
});