Skip to content

perf(run-engine,webapp): narrow the control-plane worker-version read to the columns dequeue uses - #4619

Merged
ericallam merged 1 commit into
mainfrom
feature/tri-13290-engine-control-plane-backgroundworkertask-read-ships
Aug 14, 2026
Merged

perf(run-engine,webapp): narrow the control-plane worker-version read to the columns dequeue uses#4619
ericallam merged 1 commit into
mainfrom
feature/tri-13290-engine-control-plane-backgroundworkertask-read-ships

Conversation

@ericallam

@ericallam ericallam commented Aug 14, 2026

Copy link
Copy Markdown
Member

Summary

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. That pulls large JSON columns none of this path reads (task payloadSchema/config/queueConfig/description, deployment externalBuildData/buildServerMetadata/errorData/git, queue rateLimit), 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:

  • task: id, slug, machineConfig, retryConfig, maxDurationInSeconds
  • deployment: id, friendlyId, imageReference, imagePlatform
  • queue: id, name (the queue matcher keys on both)

The shared ResolvedWorkerVersion element types narrow to match (mirrored in the cache), which also shrinks each cached worker-version entry.

Impact

The tasks read 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:

Task shape Before After Reduction
Light (no payload schema, small config) ~28 KB ~14 KB ~54%
Typical (mixed schemas / config) ~62 KB ~14 KB ~77%
Schema-heavy (large payloadSchema) ~200 KB ~14 KB ~93%

The after size is roughly fixed because the kept columns are small; the win grows with how heavy the dropped JSON is. Narrowing deployment (four JSON columns off a single row) and queues saves 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.

@changeset-bot

changeset-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 446ad0d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e1317a66-465a-4ec9-a8f1-df5d9e0405b9

📥 Commits

Reviewing files that changed from the base of the PR and between 0f35f57 and 446ad0d.

📒 Files selected for processing (1)
  • apps/webapp/app/v3/runOpsMigration/controlPlaneResolver.server.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/webapp/app/v3/runOpsMigration/controlPlaneResolver.server.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (21)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 12)
  • GitHub Check: obsmap / 🧪 Unit Tests: Observability Map
  • GitHub Check: internal / 🧪 Unit Tests: Internal
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
  • GitHub Check: typecheck / typecheck
  • GitHub Check: runops-guard / runops-guard
  • GitHub Check: fk-cascade-guard / fk-cascade-guard
  • GitHub Check: code-quality / code-quality
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (javascript-typescript)

Walkthrough

Worker resolution now selects reduced task, queue, and deployment fields across web application and run-engine paths. ResolvedWorkerVersion and dequeue results use the new resolved types. Promoted and fallback deployment results reconstruct narrowed deployment objects. The run-engine package exports the resolved types. A database-backed test verifies required fields and excludes heavy fields.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes narrowing control-plane worker-version reads to the columns used by dequeue.
Description check ✅ Passed The description clearly explains the problem, selected fields, performance impact, lack of behavior changes, and validation performed.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/tri-13290-engine-control-plane-backgroundworkertask-read-ships

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ericallam
ericallam force-pushed the feature/tri-13290-engine-control-plane-backgroundworkertask-read-ships branch 2 times, most recently from 9d4ee02 to 0f35f57 Compare August 14, 2026 12:43
@ericallam ericallam changed the title perf(run-engine,webapp): narrow the control-plane BackgroundWorkerTask read to the columns dequeue uses perf(run-engine,webapp): narrow the control-plane worker-version read to the columns dequeue uses Aug 14, 2026
… 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.
@ericallam
ericallam force-pushed the feature/tri-13290-engine-control-plane-backgroundworkertask-read-ships branch from 0f35f57 to 446ad0d Compare August 14, 2026 13:39
@ericallam
ericallam marked this pull request as ready for review August 14, 2026 13:48

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

Comment thread internal-packages/run-engine/src/engine/controlPlaneResolver.ts
@ericallam
ericallam merged commit 8dc8e1b into main Aug 14, 2026
59 of 65 checks passed
@ericallam
ericallam deleted the feature/tri-13290-engine-control-plane-backgroundworkertask-read-ships branch August 14, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants