Skip to content

Commit 6bf7f48

Browse files
authored
perf(queue): single-census read model (#1130)
The queue status read model walked the full item set repeatedly per request: twelve full traversals, seven Object.values materializations, and post-hoc sorts to find oldest entries -- O(queue-size) work multiplied per pass, on a path the dashboard polls continuously. Deferred as high-risk while the code lived inside the 15k-line Durable Object module; PR #1124's extraction to exact-review-read-model.ts made it a self-contained pure-module change. One traversal now builds a census (per-lane/state counts, oldest entries tracked during the walk, active targets, ready items, wake and Bay candidates); the public functions consume it and return byte-identical outputs with unchanged signatures. Measured: 12 -> 1 full traversals, 7 -> 1 materializations, 21.25 -> 1.67 equivalent passes. Proof: property-style equivalence against the pre-change implementation across seeded randomized queue states, plus six normalized real-Worker response comparisons (queue and status endpoints, merge-base vs head) all byte-identical, verified in a Docker-backed Crabbox container on the exact head with committed receipt.
1 parent 9c7445b commit 6bf7f48

7 files changed

Lines changed: 2208 additions & 318 deletions

File tree

‎dashboard/exact-review-queue.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ import {
156156
exactReviewQueueActiveReviewCount,
157157
exactReviewQueueAdmittedItems,
158158
exactReviewQueueBackoffReason,
159-
exactReviewQueueBayProjection,
159+
exactReviewQueueBayProjectionFromStats,
160160
exactReviewQueueBayPriorityKeys,
161161
exactReviewQueueCapacity as exactReviewQueueCapacityFromReadModel,
162162
exactReviewQueueLane,
@@ -3092,13 +3092,14 @@ export class ExactReviewQueue {
30923092
legacyStateRepoBatchEnabled: exactReviewPublicationBatchingEnabled(this.env),
30933093
maxConcurrentBatches: exactReviewPublicationBatchMaxConcurrent(this.env),
30943094
});
3095+
const bayProjection = exactReviewQueueBayProjectionFromStats(
3096+
stats,
3097+
bayPriorityKeys,
3098+
batchByItemKey,
3099+
);
30953100
return json({
30963101
...stats,
3097-
bay_projection: exactReviewQueueBayProjection(
3098-
Object.values(state.items),
3099-
bayPriorityKeys,
3100-
batchByItemKey,
3101-
),
3102+
bay_projection: bayProjection,
31023103
lanes: {
31033104
review: {
31043105
...stats.lanes.review,

0 commit comments

Comments
 (0)