Repository navigation
perf(controller): load the job catalog once per host observation - #395
Merged
Merged
Conversation
An idle observation read jobs.json and its sidecar 2N+1 times for N workers: one ActiveJob load per worker, one Upsert load per adopted container even when the merge was a no-op, and one stale-open load. enrichWorkerJobs now loads the catalog once and matches every worker through Catalog.ActiveJob, which FileStore.ActiveJob shares. indexAdopted loads once, pre-merges each patch, and calls Upsert only when the record would change; Upsert still re-merges under the store lock. The adopted catalog it returns feeds reconcileStaleOpen, so a steady-state tick costs two loads regardless of worker count. Refs #394 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #394
Summary
While idle, every 5 s host observation fully read and strictly decoded jobs.json plus runner-assign-times.json 2N+1 times for N workers. That was 9 loads of 4.64 MB on melo-lap-001 and 19 loads of 2.72 MB on melo-desk-001. It accounted for about 75% of the laptop's remaining ~0.2-core idle CPU on v0.1.26, and about 87% on the desk.
Fix
enrichWorkerJobs: loads the catalog once and matches every worker against it.ActiveJobLookupis nowLoad(ctx), which is already part ofjobindex.Store.Catalog.ActiveJob.FileStore.ActiveJobdelegates to it, so there is one copy.indexAdopted: loads once and pre-merges each patch withjobindex.Merge. It callsUpsertonly when the key is absent, the merge errors, or the merged record differs.Upsertstill re-loads, re-merges and saves under the store lock, so writes mean exactly what they did before. The pre-merge only skips the full load a no-opUpsertwould spend.Validaterejects duplicate pool/runner records. So the snapshot andUpsertalways resolve the same record.reconcileStaleOpen: reuses the catalog from adoption instead of loading again.Verification
TestStepLoadsTheJobCatalogIndependentOfWorkerCount: a realStepwith 1 and with 8 busy workers performs the same, non-zero number ofLoadcalls.TestAdoptAndCleanupLoadsTheCatalogOnceIndependentOfContainerCount: with a realFileStore, a repeat adoption of 1 or 8 containers does exactly 1Loadand 0Upsert. A new container adds exactly 1Upsert, and its record is open.go build ./...go test ./...go test -race ./...(Linux, WSL)golangci-lint run ./...(v2.13.1)CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath ./cmd/...Related
Desktop.Statusper Step.🤖 Generated with Claude Code