perf(job): two-pass listing and fast queue stats#230
Merged
Conversation
Replace per-job kv.Get() calls during filtered listing with a key-name- only status derivation pass, then fetch full details only for the paginated page. Extract computeStatusFromKeyNames pure function shared by both ListJobs and GetQueueSummary. Enforce max page size (1-100) at the OpenAPI, handler, and client levels. Also add hostname validation to agent domain handlers (get, drain, undrain) matching the node domain pattern, restore defense-in-depth validation in the file upload handler, and add corresponding tests. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Replace the slow GetQueueStats (which read every job payload) with GetQueueSummary (key-name-only derivation) for the job status endpoint. Move status counts into the ListJobs response so the CLI makes a single API call instead of two. Remove OperationCounts entirely as it required reading every job payload. Fix job status TUI rendering with alt screen. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
Thank you for contributing to this project! 😊🕹️ |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (97.03%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. @@ Coverage Diff @@
## main #230 +/- ##
==========================================
- Coverage 99.98% 99.92% -0.07%
==========================================
Files 182 183 +1
Lines 6537 6523 -14
==========================================
- Hits 6536 6518 -18
- Misses 1 3 +2
- Partials 0 2 +2
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Add architecture documentation for the two-pass job listing approach, pagination limits, and the known scalability constraint around kv.Keys() returning all keys. Fix stale GetQueueStats references. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Collaborator
Author
|
Intentionally letting coverage drop |
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.
Summary
kv.Keys()once (1 read regardless of queue size) and derives job status from key name patterns in memory — nokv.Get()calls. Pass 2 fetches full details for only the paginated page (limit=10= ~10 reads). Cost is proportional to page size, not queue size.GetQueueSummary(key-name-only). Status counts are now included in theListJobsresponse (free from Pass 1), soclient job listmakes a single API call instead of two. RemovesOperationCountswhich required reading every job payload.limit=0andlimit>100return 400). Add input validation for agent hostname params.client job statusto prevent debug log corruption during refresh.Test plan
go build ./...compilesjust go::unit— all tests passjust go::vet— lint cleango run main.go client job list— fast (~1.4s with 500 jobs, was 68s+)go run main.go client job list --status failed— fast filtered listinggo run main.go client job status— TUI renders cleanly with alt screengo run main.go client job status --json— returns stats in ~1.4s🤖 Generated with Claude Code