Repository navigation
fix(batch): keep compute admission within the worker deadline - #24211
Merged
Merged
Conversation
Use one four-second request deadline across serial executor stages and return completed decisions while deferring unfinished leases without an allow. Keep privacy, lease and attempt-refund behavior; expose bounded diagnostics. Failure-Class: FC-per-hop-timeout
Git-on-my-level
added a commit
that referenced
this pull request
Nov 1, 2026
…ple cap (#24228) ## Summary Train safety for the GMP sidecar's per-scrape `samples` cap (lead ruling 3d124a). Above the cap, GMP drops the instance's **whole** scrape, not just the new series. Backend Cloud Run max scrape, read-only GMP aggregates (`scrape_samples_scraped`, job `omi-cloud-run-application-metrics`): | Service | Max scrape | Note | |---|---|---| | backend | 9,339 now; 9,873 24h max | 3 instances, median 9,224 | | backend-sync | 7,704 | | | backend-sync-backfill | 6,769 | | | backend-integration | 6,042 | | | desktop-backend | 3,151 | | The next train adds to backend, beyond the write probe: - #24211 stage histogram: 96 - #24223: up to 18, behind a default-off flag - #24214: 2 - #24212: up to 2 That is up to about 118 samples against roughly 127 of headroom. Two changes: 1. **`OMI_FIRESTORE_WRITE_PROBE_ENABLED` kill switch** for the #24218 write probe. It is on unless the literal `false`. Off means `database._client` never wraps the transport, so no labelled write series exist in that process. That leaves 2 unlabelled counter samples. It is registered in `config/feature-flags.yaml` as `ops_kill`, and the registry doc is re-rendered. 2. **Shared Cloud Run sidecar cap 10,000 → 15,000** (`backend/deploy/cloud_run_gmp_sidecar.yaml`: backend, desktop-backend, notifications-job). Today backend is about 1% from losing all metrics on any new series; this restores headroom. GMP bills per sample emitted, so the cap itself costs nothing. The sync sidecar (`cloud_run_gmp_sync.yaml`, max 7,704) is unchanged. Series behaviour: - **Write probe series are per instance.** They grow with code-path diversity (distinct caller × collection × op an instance has executed, capped), not with write volume. - **At batch 100%**, instance count may grow and each instance sees more batch callers. Per-instance cardinality rises toward the caps, not with load. Recommended for the train: merge this. If the cap raise is not wanted in this train, set `OMI_FIRESTORE_WRITE_PROBE_ENABLED=false` on backend Cloud Run only. Sync, listen and pusher keep the probe. ## Product invariants affected none. Observability config only; no data path. ## Verification All runs used `backend/test.sh` under `bin/omi-heavy` + `nice -n 19`, at the unit layer: - `test_firestore_write_probe.py`: 16 passed, including the kill switch (literal `false` and ` FALSE ` leave `FirestoreClient.commit` unwrapped; unset, empty, `true`, `0`, `off` stay on). - The other tests that read the sidecar config: `test_attach_cloud_run_gmp_sidecar` (117), `test_external_list_cache`, `test_fleet_deployment`, `test_parakeet_request_metrics`, `test_relevance_metric_is_scraped`, `test_sync_absorption_metrics`. All pass. - `scripts/check_feature_flag_registry.py`: OK. ## Rollback Set the switch to `false` on any service, or revert. The cap can return to 10,000 only if the max scrape is well below it. Failure-Class: none 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/24228?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/24228?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24228&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
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.
Compute admission currently evaluates a whole lease group serially and can answer after the worker's five-second HTTP timeout, discarding every completed decision. This change gives the server one four-second monotonic budget and returns the decisions completed so far. Unfinished and unreached leases get retry-after 30, with no allow and no fabricated policy hold.
Each blocking read, policy check, reservation and seal runs on the existing DB executor with the remaining request budget. The route awaits the coordinator directly, so executor queue time is included. Evaluation stays serial: current fresh funding/fair-use checks are check-then-act, with no in-flight usage reservation. Parallelizing them cannot be proven safe and would widen the documented overshoot risk. The existing privacy read, lease fence and scheduler attempt refund are retained. Worker code, retry ladder and levers are unchanged; the current ComputeClient parses partial receipts without a worker roll.
Already-running synchronous Firestore/Redis calls cannot be preempted by cancelling their executor future. Transaction retries and commit, privacy/intake reads, monthly allowance reads and reservations can therefore outlive the response. Firestore keeps its existing SDK/retry limits; the shared Redis client does not configure a socket timeout, so its executor occupancy is not bounded by this change. No later stage is scheduled and no late result enters the receipt. Queued calls and seal callbacks check expiry before starting/writing. A reservation or commit already issued may finish conservatively; the unfinished lease still has no allow in the response. Bounding those RPCs themselves requires passing remaining budgets through shared DB/policy helpers and a bounded Redis client, outside this change. This residual risk is tracked in card:gpucpu-20261101 for the rollout lead.
Admission exports
omi_batch_compute_admission_stage_secondsfor static substages (including executor wait and time until cancellation). Per-lease failures log onlybounded_exception_class, without exception text or identifiers. No new reason label is introduced.Validation:
BACKEND_UNIT_TEST_FILE_LIST=/Volumes/Ephemeral/scratch/gpucpu/targeted-tests.txt backend/test.sh, underomi-heavyandnice -n 19: 229 passed across admission (44), current client (21), serving (51), provider (94) and reason-label (19) tests. Covers partial receipt, slow read/funding/restriction/reservation/seal, unreached leases, same-owner serial funding, exception sanitization, privacy/lease/refund regressions, unchanged worker decoder and real FastAPI HTTP route with the default four-second budget.omi-heavy run -- nice -n 19 bash backend/testing/e2e/run.sh -k sync: 11 passed (174 deselected), hermetic local lifecycle layer.omi-heavy run -- nice -n 19 env OMI_PR_BODY_FILE=<draft> make preflight: passed, including async, policy, serving-query, runtime-image source closure and documentation gates.Failure-Class: FC-per-hop-timeout