Repository navigation
feat(stt): measure routing-arm first text at on/100 - #22230
Merged
Merged
Conversation
Failure-Class: none
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. |
Failure-Class: none
Git-on-my-level
added a commit
that referenced
this pull request
Oct 20, 2026
…req / 35 ws per pod (#22934) ## Summary D0b from `plan-d-realtime-gateway.md` §1/§5 and `cost-gap-plan-2026-10-20.md` lever #6. Prod listen now scales on CPU. Before this, only socket metrics drove scaling (22 ws/pod and 10 upgrades/pod). This is a config-only change to `prod_omi_backend_listen_values.yaml`: | autoscaling key | before | after | |---|---|---| | `targetCPUUtilizationPercentage` | (commented out) | **55** | | `activeConnectionsPerPod` (ws guard) | 22 | **35** | | `requestsPerPod` (LB-request guard) | 10 | **16** | | `minReplicas` / `maxReplicas` | 40 / 60 | unchanged (the lead lowers the floor separately) | **Why 55% and not the plan's 70%.** The HPA takes the maximum across its metrics and ignores ratios within 10% of target. A target T therefore only scales out once mean CPU exceeds about 1.1×T. During the 2026-10-19 incident (15:10–17:25Z), mean listen CPU per pod peaked at 0.56–0.65 of the 1-CPU request (10-minute means) while the hottest pods saturated. At 70%, and also at 60%, the HPA would never have acted. At 55% it acts above about 0.60, which would have fired in the 16–17Z window. The plan's figure of about 17 pods at p50 assumes about 90% utilization; per-pod CPU is too uneven for that. **Why both socket guards rise together.** Raising them is for the later floor drop, not for this roll. Live HPA right now: 14.8 ws/pod (target 22) and 8.8 on `backend_listen_requests_per_pod` (target 10) at 40 pods. That second metric is every LB response code over a 3-minute window divided by replicas (prod adapter, no `101` filter), so 8.8 means about 117 LB requests a minute in total, not concurrent upgrades. At the old targets the guards would hold about 36 and 27 pods. That is below the floor of 40 today, but it would pin listen near 36 once the floor drops, so CPU could never take over. At 16 and 35 they bind near 22 and 17 pods at today's peak, so they act only on connection or request surges. With the old guards, CPU would still have scaled out at the incident mean (ceil(40 × 0.65 / 0.55) = 48), because the HPA takes the max. Neither guard was dropped. The guards cap the per-pod average; they do not cap the hot pod. Evidence (ro-prod tier, Cloud Monitoring aggregates only: `kubernetes_io:container_cpu_request_utilization` for the backend-listen container, kube-state-metrics HPA status, and a `kubectl get hpa` status read of the metric values only): - Last 7 days: mean CPU 0.42 at p50 and 0.62 at p95. Across pods, the p95 pod is at 0.66 at p50. The hottest pod sat at about 2.0 cores (the limit) from 06Z to 18Z on 10-20. - Pre-incident week (10-13 to 10-19, floor 12): 28.7 pods at p50. - Last 24h (floor 40): mean CPU 0.34 to 0.63. The peak is 16–18Z, with 25 cores across 40 pods. ## Expected pod count by hour (UTC) Computed from the last 24h as mean CPU × replicas ÷ 0.55, rounded up. From N ready pods the HPA moves only when the recommendation leaves ±10% of N. From 40, scale-up needs a recommendation of at least 45. Scale-down then runs at 1 pod per 120s after a 600s window, so 46 → 40 takes about 20 minutes. | hour | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---| | CPU recommendation | 33 | 35 | 32 | 27 | 27 | 25 | 25 | 29 | 30 | 28 | 30 | 30 | 30 | 35 | 38 | 41 | 43 | 45 | 46 | 36 | 33 | 34 | 33 | 32 | | as shipped (floor 40) | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 45 | 46 | 40→ | 40 | 40 | 40 | 40 | - **As shipped (floor 40):** 15–16Z sit inside the deadband and stay at 40. 17–18Z go to 45–46, then decay back to 40 within about 20 minutes. That is about 12 extra pod-hours a day, roughly +$1/day, as headroom in the hours that degraded on 10-19. That is all this PR changes on its own. - **After the lead lowers the floor (for example to 25):** about 33 pods mean versus 40 today, roughly −$16/day at today's per-pod CPU. Before lowering, confirm the checked-in `prod_omi_backend_listen_cronjob.yaml` (which patches the floor to 10 at 01Z and 30 at 11Z) is still not applied. Today `kubectl get cronjob -A` under ro-prod returns none. - **Path to the plan's −$25/day:** it needs the D0a CPU fix (per-flush re-encode) to cut cores. Cores per hour at peak are about 25% above the pre-incident week. ## Rollout and watch Ship this in an off-peak listen roll that the lead schedules, **not** together with the STT-routing fix roll, so the two listen changes stay separately attributable. Watch for 24h: - Event-loop lag: `histogram_quantile(0.99, sum by (le) (rate(omi_listen_event_loop_lag_seconds_bucket[5m])))` < 50 ms. This is the D0b gate in `backend/docs/listen_pusher_pipeline.mdx`. It lives in the in-cluster Prometheus, not GMP. - Session failures: listen session terminal-failure and close-code rates, live STT exhausted/accepted (10-19 baseline 0.25–0.27), and Soniox `connection_lost` per 10m. - First-text latency per arm (#22230), plus terminal-after-text. - HPA: `kube_horizontalpodautoscaler_status_desired_replicas` should track the table above. Hottest-pod CPU should stay below the 2-core limit, and liveness/readiness probe timeouts should not reappear. Known limit: a mean-CPU target does not rebalance a single hot pod; the long-lived sockets stay where they are. That hot pod existed before this change. D0a, or the edge gateway, is the fix for it. ## Review Grok: no blockers. Every should-fix is addressed in the second commit: - the deadband-corrected table; - the guard rationale and the corrected units for `backend_listen_requests_per_pod`; - the test now pins the reviewed values; - the CronJob was checked (not in the cluster); - the stale D0b docs are updated; - the rollback timing is corrected. ## Lane / contract Lane pusher-d0b (10-20 swarm P5 Part B); owner sign-offs for edits to other lanes' files: none ## Product invariants affected none ## Verification - `backend/test.sh` on `test_backend_listen_helm_defaults.py`: 10 passed. Layer: unit plus a local `helm template` render. - New test `test_prod_listen_hpa_scales_on_cpu_with_socket_guards` renders the prod chart. It asserts a CPU Utilization metric below 60% and pins the reviewed values: CPU 55, guards 16 and 35, floor and ceiling 40 and 60. The `listen_pusher_pipeline.mdx` and `listen_loop.py` text that called the D0b gate "CPU 70%, before the retune" now describes 55% and a 24h watch after the roll and before the floor drop. - Not run: any deploy. HPA behavior under load is measured only after the lead's off-peak roll. ## Rollback Revert this PR (`targetCPUUtilizationPercentage` back to commented out, guards back to 22 and 10) and roll listen. For an immediate effect without a roll, an operator can patch the HPA metrics. The HPA re-evaluates on its next 15s sync. Scale-down still honors the 600s window plus 1 pod per 120s, so 46 → 40 takes about 20 minutes. A chart-only listen upgrade that keeps the running image does not change the pod template, so it updates the HPA without dropping websockets. 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/22934?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/22934?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F22934&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.
Prod listen stays
STT_ROUTING_MODE=on,STT_ROUTING_ON_PERCENT=100. This PR ships only the first-text instrumentation and runbook, preserving production allocation. A separate draft stage-1 PR will carry on/95 after the instrumented image has served on/100 for at least 60 minutes, withimage_tagpinned to that same image.Adds
omi_stt_routing_cohort_window_first_text_seconds{routing_arm}at the existing Parakeet-window first-emitted-text seam. The window socket pins the managed session's arm before background work; onlyoff,shadow, andonlabels exist. Existing histograms retain their schema and semantics. This is window-leg latency, not all-provider end-to-end timing; unmanaged sockets are excluded.The runbook specifies 95→90→75→50→0, stage sample/dwell floors, concurrent-control gates, operator review, and rollback to on/100 on the same image. Chart, prod overlay, generated runtime manifest and flag documentation retain on/100. The pipeline contract describes the separate stage-1 change. No merge or deployment is included.
Image investigation: the canary/rollback image
5bb18b1was not identical toecd1f40. #22134's metrics are exception-isolated, and global off skips the scheduled score/cost writes; its backoff correction preserves the deadline when no Redis write is attempted. #22075 adds one cohort document read per account/pod/cache lifetime (60s), awaited up to 1.25s before the listen session, with a separate 4-worker/64-queue executor. That is an admission confound, but the late first-text metric begins after VAD speech, and rollback did not uniformly restore metrics. Neither hunk is causally established as the regression, so this PR contains no speculative health/cohort revert.Validation: 255 focused tests passed (187 window, 27 cohort, 12 health-write fault/backoff, 29 resolver), plus 320 hermetic pre-deploy tests. Tests used nice -n 19 through omi-heavy. Full repository preflight passed all 38 checks after a serial rerun resolved a concurrent temporary OpenAPI-directory cleanup race. Normal pre-commit/pre-push hooks passed, including selected unit tests, Pyright (zero errors), 17-image source closure, and runtime/deployment contracts. The tests exercise real window/VAD/POST/receiver seams with synthetic providers; production acceptance awaits a separately authorized rollout.
Failure-Class: none
Product-Invariants: INV-MEM-4
INV-MEM-4: preserved. The generated runtime manifest retains listen routing allocation at on/100; canonical intake, promotion receipts, memory authority and projections retain their existing configuration and behavior.
This is bounded observability and the runbook for a separately gated allocation experiment; it does not change account migration authority, credentials, data-plane routing, or user data. No GitHub workflow change.