Repository navigation
perf(batch): batch cross-owner publication and per-flight merge drains - #22362
Merged
Merged
Conversation
After a GPU flight the pump published one fenced transition at a time and ran an ordered drain after every accepted transition. Owners now publish concurrently under a bounded knob (BATCH_PIPELINE_PUBLISH_CONCURRENCY, default 4; 1 restores the serial path), and each owner gets one drain per flight after all of its transitions land. Every transition remains its own lease-fenced transaction; same-owner drains are serialized by a per-owner lock and the merge still commits the capture-order head. Maintenance drains each result_ready owner once, bounded the same way. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Jobs blocked behind an ordered predecessor were re-read every 5s sweep just to find their (immutable) owner. A bounded segment->owner memo, fed by leases and first reads, removes those repeated reads when publication concurrency is on; the kill switch keeps the legacy read-per-sweep path. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[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. |
# Conflicts: # backend/config/batch_pipeline.py
… registry Registry and deployment-setting classification only, matching how BATCH_PIPELINE_WORKER_IO_CONCURRENCY is registered. No logic change. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # backend/utils/batch_pipeline/pump.py
Git-on-my-level
added a commit
that referenced
this pull request
Oct 19, 2026
…22425) * feat(rollout): runtime _ramp percents and the ramp controller (lane 6 M1) Contract (f): rollout_cohorts/_ramp holds per-env percents and legacy_sync. utils/rollout/runtime_percent.py reads it with a 30s process cache on the rollout executor, serves last-known-good on error, and falls back to the env value on a cold start or a missing document, so with no document behaviour is unchanged. config/ reaches it through a resolver seam in config/rollout_cohorts.py, bound by configure_rollout_runtime(). Unbound processes keep env values. summary_guarantee and batch_live_preview now read their percent through the seam. valid_uid rejects _ramp* ids. CAS writes create a history row in the same transaction and refuse range or nesting violations. Contract (g): scripts/rollout/ramp_controller.py has a pure decide() and a thin runner. The runner writes only the batch-pipeline/first-summary percents and acts only while legacy_sync=on. It moves one step at a time, at most once per 10 minutes, and never past 100. It uses the fleet gate's data-loss tokens for ROLLBACK_ZERO and stops after two rollbacks in 24h until a human lock_cleared write. Every decision goes to STATE and every action to anx. After a sleep or restart gap, the first tick only holds (S9). scripts/rollout/ramp_set.py is the operator CLI. inject_gate.py is the staging-only rehearsal wrapper. config/batch_pipeline.py is untouched (frozen until #22362/#22373 reach integration). Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(rollout): align runtime_percent with the lane 1 stub; no package __init__ files Snapshot source 'firestore' and revision int (0 = no document) match lr/01-stubs. RAMP_DOC_ID re-exported. utils/rollout and scripts/rollout are namespace packages, because the dead-code ratchet blocks __init__.py there. LIFECYCLE headers are now on line 1. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(rollout): run _ramp reads in a fresh context, never the request's Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(rollout): C1 gate-unavailable escalation; BYOK not re-held at dispatch C1 (lead ruling): a gate that cannot run (ro_prod_unavailable, timeout_incomplete, parity_not_run, ...) holds. After 3 consecutive such ticks (~30 min) the controller pages the lead, then pages again every 3 ticks. The streak lives in the heartbeat file, so it survives a restart; a pause gap resets it. admission.authorize: admission decides funding once (contract (c)). A unit whose admission policy snapshot records provider_reason=byok skips the dispatch-time funded re-check, which runs without the user's keys or BYOK consent and would re-hold a BYOK owner on every lease (David: BYOK routes like everyone). A missing or other policy keeps today's re-check, so this stays behaviour-neutral until E1 writes binding.policy. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Git-on-my-level
added a commit
that referenced
this pull request
Oct 19, 2026
, #22362, #22461, #22471 sync) - config/feature-flags.yaml: kept both new rows (LISTEN_LOOP_METRICS_ENABLED from main, ENRICHMENT_ROUTE from integration); rendered doc regenerated. - #21932 moved the legacy sync runner's 500/503 into _run_sync_job_attempt: known gaps and the task-target KNOWN set gain the four _run_sync_job_attempt keys (legacy, leave with C11), drop the _run_sync_job_body/503 keys and recover_quarantine/503 (fixed by #22476).
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.
What changed and why
After every GPU flight the dedicated batch pump published results one fenced transition at a time, and ran
drain_owner(up to 100 ordered commits plus an empty probe) after each accepted transition. Every 5 s the maintenance sweep also re-read eachresult_readyjob, one transaction at a time, only to learn its owner, including jobs blocked behind an ordered predecessor that it had already read on the previous sweep. All of this sits in the pump's serial chain between GPU flights (see the worker profile's "Cheapest fix": bounded cross-owner publication with one drain per owner per flight).This PR changes three things in
backend/utils/batch_pipeline/pump.py:BATCH_PIPELINE_PUBLISH_CONCURRENCYin flight. Each transition is still its own lease-fenced transaction.result_readyowner once, under the same bound. A bounded (4096-entry) segment→owner memo means a blockedresult_readyjob is read once rather than on every sweep. A segment's owner cannot change after admission, so a stale entry can only cause a harmless fenced probe.Kept intact:
OrderedMerge.commit_nextstill commits only the owner's first pending entry, and a per-owner lock in the pump stops two drains from racing on an owner's log tail.owns_lease, lost-lease heartbeat re-check) is unchanged.complete()remains idempotent for a duplicate delivery. Quarantine still produces exactly onerecovery_state='held'. The paid-recovery intent is created downstream from that state and is untouched here.Config (ship-on, with a kill switch):
BATCH_PIPELINE_PUBLISH_CONCURRENCYdefaults to 4. Values run from 1 to 16. Setting it to1restores the exact legacy serial path: lease order, a drain after every accepted transition, and a re-read on every sweep. A malformed value also falls back to1. The simulation produced byte-identical numbers for the kill switch and the unmodified main pump.Scope: this PR covers post-flight publication and the ordered merge only. Flight overlap,
process_batchI/O and model batching are owned by other lanes.Product invariants affected
none
How it was verified
Measurement setup. I used the virtual-clock simulation from #22201 (now on main) with one GPU pump (one replica) and batch size 8. Arrivals ran for 30 minutes: the 5% cohort at about 20 jobs/min (10 owners), and the upper end of the 25% cohort at about 100 jobs/min (50 owners).
The stock simulation charges zero virtual time for pump database calls, so on its own it cannot see publication or merge cost. A measurement-only harness (not in this PR) adds a Firestore round-trip model: each pump transaction or query costs
db_msof virtual time, bounded to 24 concurrent calls likedb_executor. GPU work is modelled asgpu_s/item.The before/after columns compare kill switch
1with the default4. I checked the "before" numbers against the unmodified main pump and they are byte-identical. Values are means over seeds 1–3 atdb_ms=50.commit_nextcalls per jobSensitivity to database latency (seed 1, 25% rate, gpu 2.0 s/item, leases/min):
Concurrency 8 measured the same as 4 (18.9 leases/min), so 4 is the conservative default.
What the numbers do and don't show:
Tests: targeted runs only, under
bin/omi-heavy run -- nice -n 19 bash test.shwithBACKEND_UNIT_TEST_FILE_LIST. Files:test_batch_pipeline_{publication,pump,worker,serving,quarantine,validation_disposition,runtime,scheduler,cohort_config}.pyandtest_pipeline_sim*.py. All passed.test_cancel_waits_for_nonpreemptible_compute_before_heartbeat_stopsfailed once under load and then passed in three isolated reruns. It is timing-sensitive (a 0.02 s sleep against a 0.04 s worker) and exercises the cancel path before publication, which this PR does not change.Tests
New file
backend/tests/unit/test_batch_pipeline_publication.py:previous_segment_id/log_sequencechain hold at concurrency 1, 4 and 16, with results returned out of capture order.jobs/results/ownersunchanged, and quarantine is held once.result_readyjobs on every sweep.UI evidence
UI-Evidence: none -- backend worker only
Failure class (fixes)
Failure-Class: none
🤖 Generated with Claude Code