perf(queue): fan build-contributor-evidence out into per-batch jobs (config-driven) - #2005
Conversation
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 Gittensory review result - fixes requiredReview updated: 2026-07-01 08:25:18 UTC
🛑 Suggested Action - Manual Review
Review summary Nits — 6 non-blocking
CI checks failing
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
|
Rebased onto main to resolve the `queue-common.ts` conflict from #2001 (the event-job coalescing that just merged): Also tightened the coalescing contract the review flagged: a fanned-out batch can no longer fall through to the |
bd115cc to
735080f
Compare
❌ 1 Tests Failed:
View the full list of 1 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
735080f to
36cc5f6
Compare
…config-driven)
The scheduled build-contributor-evidence job resolved up to 500 contributors'
GitHub reads (/users/{login} + its uncached repos pages) in ONE job — a burst in
the 6-hourly full-sync window. The cron trigger now derives the login set and
fans out into per-batch jobs (CONTRIBUTOR_EVIDENCE_BATCH_SIZE, default 150), so
the per-login reads spread across the queue's paced execution + rate-limit
admission. Each batch loads the aggregate data once and processes its batch; the
single-login path is unchanged; 0 disables the fan-out.
A batch coalesces by its FIRST login (batches are disjoint slices → unique heads)
so distinct batches never collapse into one :all key (which would drop work).
Advances #1936.
…tributor-evidence The evidence fan-out landed at 93.75% patch coverage with two partial branches: the explicit-`logins` batch arm (a fanned job was created but never processed) and the `record.authorLogin ? … : []` filter's empty arm (no fixture record lacked an author). Add two invariant tests: a fanned batch job processes exactly its `logins` without re-deriving or re-fanning, and a null-author (ghost/deleted account) record is filtered out of the derived contributor set. Diff-range branch coverage is now complete.
36cc5f6 to
f6c162f
Compare
Summary
The scheduled
build-contributor-evidencejob resolved evidence for up to 500 contributors in ONE job — each doing a/users/{login}read plus its (uncached, paginated)/users/{login}/reposreads — so the whole set bursts against GitHub in a single execution during the 6-hourly full-sync window.This makes the scheduled trigger fan out into per-batch jobs so those per-login reads spread across the queue's paced execution + rate-limit admission instead of bursting:
build-contributor-evidencejob per batch ofCONTRIBUTOR_EVIDENCE_BATCH_SIZElogins (staggered), and returns.CONTRIBUTOR_EVIDENCE_BATCH_SIZE(default 150,0= disable → the pre-existing single job). A set that fits one batch stays a single job, so small instances see no change.Trade-off (called out honestly): because each per-login computation needs the full aggregate (
buildContributorFit/buildContributorOutcomeHistorycross-reference all PRs/issues), each batch re-loads that shared data. So fan-out trades a boundedceil(N/batchSize)×DB re-read for spreading the GitHub burst — which is the right trade on a rate-limited instance, and the batch size lets operators tune it (or turn it off).Footgun avoided: a fanned-out batch coalesces by its first login (batches are disjoint slices, so heads are unique) — distinct batches never collapse into one
:allkey (which would silently drop all-but-one batch). A duplicate re-enqueue of the same batch still coalesces.Advances #1936 (rec #2 of the #1941 read-reduction audit).
Validation
git diff --check,npm run typechecknpm run test:coverage— new tests: the fan-out enqueues one batch job per login above the size; the disabled (0) path stays a single inline job; the batch-size reader defaults on unset/invalid/negative; and the batch coalesce key is unique per batch (never:all). Existing single-login + inline evidence tests still pass.npm run test:ci,npm audit --audit-level=moderateCONTRIBUTOR_EVIDENCE_BATCH_SIZEis read viaprocess.env(works on cloud + self-host), documented in.env.example.Safety
0fully disables the fan-out.