perf(run-engine,webapp): narrow the control-plane worker-version read to the columns dequeue uses - #4619
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (21)
WalkthroughWorker resolution now selects reduced task, queue, and deployment fields across web application and run-engine paths. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
9d4ee02 to
0f35f57
Compare
… to the columns dequeue uses
The worker-version resolve path fetched every column of every
BackgroundWorkerTask for a worker (include: { tasks: true }) plus full
WorkerDeployment and TaskQueue rows just to match one task at dequeue, pulling
large JSON columns none of this path reads (task payloadSchema, config,
queueConfig, description; deployment externalBuildData, buildServerMetadata,
errorData, git; queue rateLimit).
Replace the includes with explicit selects of only the columns dequeue uses,
in both the passthrough resolver and the app resolver: task { id, slug,
machineConfig, retryConfig, maxDurationInSeconds }, deployment { id, friendlyId,
imageReference, imagePlatform }, queue { id, name }. The shared
ResolvedWorkerVersion element types narrow to match, which also shrinks each
cached worker-version entry. No behavior change.
0f35f57 to
446ad0d
Compare
Summary
The worker-version resolve path fetched every column of every
BackgroundWorkerTaskfor a worker (include: { tasks: true }), plus fullWorkerDeploymentandTaskQueuerows, just to match one task at dequeue. That pulls large JSON columns none of this path reads (taskpayloadSchema/config/queueConfig/description, deploymentexternalBuildData/buildServerMetadata/errorData/git, queuerateLimit), so each resolve transfers and deserializes far more than it uses.Fix
Replace the includes with explicit
selects of only the columns dequeue reads, in both the passthrough resolver and the app resolver:id,slug,machineConfig,retryConfig,maxDurationInSecondsid,friendlyId,imageReference,imagePlatformid,name(the queue matcher keys on both)The shared
ResolvedWorkerVersionelement types narrow to match (mirrored in the cache), which also shrinks each cached worker-version entry.Impact
The
tasksread fetches every task of a worker to match one, so its cost scales with task count and payload-schema size. For a worker with ~70 registered tasks, dropping the unread columns cuts the per-query transfer roughly:payloadSchema)The
aftersize is roughly fixed because the kept columns are small; the win grows with how heavy the dropped JSON is. Narrowingdeployment(four JSON columns off a single row) andqueuessaves further on top.No behavior change: pure read-shape narrowing, no flag and no schema change, so rollback is a plain revert. Verified with a red/green run-engine test that asserts the resolved task, deployment, and queue carry only the used columns, plus the queue feature-matrix runs (batch, retry-policy, machine-preset, plain trigger) that exercise the kept columns.