Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
33c32fe
feat(run-engine): concurrency-key virtual-time key builders
1stvamp Jul 23, 2026
d273112
feat(run-engine): ckVirtualTimeScheduling options flag
1stvamp Jul 23, 2026
0703412
feat(run-engine): two-pass virtual-time CK dequeue command
1stvamp Jul 24, 2026
31d4af1
feat(run-engine): register CK variants in vtime index on enqueue
1stvamp Jul 24, 2026
bd33649
feat(run-engine): re-register CK variants in vtime index on nack
1stvamp Jul 24, 2026
788d4cd
test(run-engine): fairness scenarios on the real batched dequeue path
1stvamp Jul 24, 2026
961e215
test(run-engine): multi-consumer correctness + op-count budget
1stvamp Jul 24, 2026
0232818
test(run-engine): default-off regression proof
1stvamp Jul 24, 2026
852ee4c
feat(run-engine,webapp): wire ckVirtualTimeScheduling env flag (code-…
1stvamp Jul 24, 2026
d7dfc8e
chore(run-engine): ship note + comment/format cleanup
1stvamp Jul 24, 2026
deceeef
fix(run-engine,webapp): address whole-branch adversarial review
1stvamp Jul 24, 2026
59c4957
docs(run-engine): record CK vtime known limitations for GA decision
1stvamp Jul 24, 2026
d2830e6
docs(run-engine): plan + references for virtual-time CK fair scheduling
1stvamp Jul 23, 2026
bbac8d8
docs(run-engine): add fairness explainer diagrams
1stvamp Jul 24, 2026
44351e8
fix(run-engine): move design docs out of the Mintlify docs/ tree; format
1stvamp Jul 24, 2026
2351488
docs(run-engine): tighten CK fairness server-changes note
1stvamp Jul 24, 2026
ddb46ff
docs(run-engine): fix stale references in the CK fairness design docs
1stvamp Jul 26, 2026
89039fe
docs(run-engine): add CK virtual-time A/B benchmark plan and harness
1stvamp Jul 27, 2026
de552f2
docs(run-engine): make the e2e bench harness work on self-hosted
1stvamp Jul 27, 2026
2008de9
docs(run-engine): add CK virtual-time benchmark results
1stvamp Jul 27, 2026
1b6fa74
chore(run-engine): gitignore benchmark output artifacts
1stvamp Jul 27, 2026
c08c852
docs(run-engine): benchmark Redis CPU and memory vs concurrency-key c…
1stvamp Jul 28, 2026
c68802d
chore(run-engine): drop benchmark, e2e, and design docs from the branch
1stvamp Jul 28, 2026
d987b3f
fix(run-engine): stop an unservable variant pinning the ck virtual-ti…
1stvamp Jul 31, 2026
ea99e0d
fix(run-engine): advance the ck virtual-time floor from servable vari…
1stvamp Jul 31, 2026
d3f3dfe
fix(run-engine): keep unservable ck variants in the fair order
1stvamp Jul 31, 2026
887617d
fix(run-engine): make ck vtime pass 2 discover unregistered variants
1stvamp Aug 3, 2026
2b6c8a3
test(run-engine): bound the ckManyKeys first-serve claim
1stvamp Aug 3, 2026
8cd0241
test(run-engine): pin the ck vtime window-freeze and stranded-entry b…
1stvamp Aug 6, 2026
d42a28d
docs(run-engine): note the ck vtime retry-storm fallback in the relea…
1stvamp Aug 6, 2026
2c7d37c
fix(run-engine): stop unready ck variants blocking the fair pass, and…
1stvamp Aug 15, 2026
05d412f
fix(run-engine): guard the wildcard cleanup in the ck vtime scripts
1stvamp Aug 15, 2026
1af0d09
fix(run-engine): register a gated ck variant so it can rejoin the fai…
1stvamp Aug 16, 2026
8ba60af
fix(run-engine): drop drained ck variants from the fair order on ack,…
1stvamp Aug 17, 2026
81d71c3
fix(run-engine): remember a drained ck variant's virtual time
1stvamp Aug 18, 2026
5015505
fix(run-engine): bound the ck idle set by rank, not just by floor
1stvamp Aug 18, 2026
f7a15b3
perf(run-engine): cut two Redis calls from the ck vtime registration …
1stvamp Aug 19, 2026
35ef53d
perf(run-engine): stop re-registering ck variants already in the fair…
1stvamp Aug 19, 2026
893e393
fix(run-engine): keep the ck vtime floor alive alongside the tags it …
1stvamp Aug 19, 2026
14fb481
docs(run-engine): cut the ck fair scheduling release note down to the…
1stvamp Aug 19, 2026
f65f3c4
fix(run-engine): register a brand-new ck variant behind the pack, not…
1stvamp Aug 20, 2026
cd8891d
test(run-engine): pin the fresh-key fix and isolate the ck idle rank cap
1stvamp Aug 20, 2026
021691d
fix(run-engine): stop the ck arrival cap from being reachable
1stvamp Aug 20, 2026
4286a06
fix(run-engine): stop concurrency-gated ck variants eating the fair pass
1stvamp Aug 21, 2026
4a6ff58
test(run-engine): cover the future-head window guard a mutation audit…
1stvamp Aug 21, 2026
6ef1fd0
test(run-engine): pin the ck vtime credit round trip and TTL registra…
1stvamp Aug 21, 2026
09b1943
fix(run-engine): stop the gated ck batch rewinding a live virtual-tim…
1stvamp Aug 21, 2026
c8c8d6a
test(run-engine): pin the parked tag a gated variant registers with
1stvamp Aug 21, 2026
5893e3f
docs(run-engine): cut the ck vtime comments back to what the code can…
1stvamp Aug 21, 2026
d9c767c
fix(run-engine): re-register the TTL entry when the vtime dequeue exp…
1stvamp Aug 21, 2026
9880c82
fix(run-engine): keep parked ck credit when pass 2 repairs a variant
1stvamp Sep 7, 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
6 changes: 6 additions & 0 deletions .server-changes/2026-07-24-ck-fair-scheduling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
area: webapp
type: feature
---

One concurrency key with a large backlog no longer holds up runs waiting on other keys on the same queue.
7 changes: 7 additions & 0 deletions apps/webapp/app/env.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,13 @@ const EnvironmentSchema = z
RUN_ENGINE_TTL_CONSUMERS_DISABLED: BoolEnv.default(false),
RUN_ENGINE_TTL_WORKER_BATCH_MAX_WAIT_MS: z.coerce.number().int().default(5_000),

// Fair (virtual-time) ordering across concurrency-key variants of a base queue.
// Off by default; when off the run queue behaves exactly as before.
RUN_ENGINE_CK_VTIME_SCHEDULING_ENABLED: BoolEnv.default(false),
RUN_ENGINE_CK_VTIME_QUANTUM: z.coerce.number().int().positive().default(1),
RUN_ENGINE_CK_VTIME_WINDOW_MULTIPLIER: z.coerce.number().int().positive().default(3),
RUN_ENGINE_CK_VTIME_STATE_TTL_SECONDS: z.coerce.number().int().positive().default(86400),

/** Optional maximum TTL for all runs (e.g. "14d"). If set, runs without an explicit TTL
* will use this as their TTL, and runs with a TTL larger than this will be clamped. */
RUN_ENGINE_DEFAULT_MAX_TTL: z.string().optional(),
Expand Down
8 changes: 8 additions & 0 deletions apps/webapp/app/v3/runEngine.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ function createRunEngine() {
batchMaxSize: env.RUN_ENGINE_TTL_WORKER_BATCH_MAX_SIZE,
batchMaxWaitMs: env.RUN_ENGINE_TTL_WORKER_BATCH_MAX_WAIT_MS,
},
ckVirtualTimeScheduling: env.RUN_ENGINE_CK_VTIME_SCHEDULING_ENABLED
? {
enabled: true,
quantum: env.RUN_ENGINE_CK_VTIME_QUANTUM,
scanWindowMultiplier: env.RUN_ENGINE_CK_VTIME_WINDOW_MULTIPLIER,
stateTtlSeconds: env.RUN_ENGINE_CK_VTIME_STATE_TTL_SECONDS,
}
: undefined,
},
runLock: {
redis: {
Expand Down
1 change: 1 addition & 0 deletions internal-packages/run-engine/src/engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ export class RunEngine {
workerItemsSuffix: "ttl-worker:{queue:ttl-expiration:}items",
visibilityTimeoutMs: options.queue?.ttlSystem?.visibilityTimeoutMs ?? 30_000,
},
ckVirtualTimeScheduling: options.queue?.ckVirtualTimeScheduling,
});

this.worker = new Worker({
Expand Down
5 changes: 4 additions & 1 deletion internal-packages/run-engine/src/engine/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from "@trigger.dev/redis-worker";
import type { ControlPlaneResolver } from "./controlPlaneResolver.js";
import type { FairQueueSelectionStrategyOptions } from "../run-queue/fairQueueSelectionStrategy.js";
import type { RunQueueMetricsEmitter } from "../run-queue/index.js";
import type { RunQueueMetricsEmitter, RunQueueOptions } from "../run-queue/index.js";
import type { MinimalAuthenticatedEnvironment } from "../shared/index.js";
import type { LockRetryConfig } from "./locking.js";
import type { workerCatalog } from "./workerCatalog.js";
Expand Down Expand Up @@ -126,6 +126,9 @@ export type RunEngineOptions = {
/** Max time (ms) to wait for more items before flushing a batch (default: 5000) */
batchMaxWaitMs?: number;
};
/** Fair (virtual-time) ordering across concurrency-key variants of a base queue.
* Passed through to RunQueue; off by default (undefined = today's behaviour). */
ckVirtualTimeScheduling?: RunQueueOptions["ckVirtualTimeScheduling"];
};
runLock: {
redis: RedisOptions;
Expand Down
Loading
Loading