Repository navigation
SCA-2302: instrument optional PCM codec stages - #25414
Merged
Merged
Conversation
The whole-helper histogram cannot say which codec child consumed the time or
how far a killed child overran its own budget, so a latency question about the
optional PCM representation step could not be answered from production data.
Add two diagnostic histograms beside the unchanged guard:
- omi_audio_pcm_storage_stage_seconds{stage,child_result} times one child that
actually ran, from just before subprocess.run through its return or handled
exception. child_result is that child's own outcome (success/timeout/error),
never the call's terminal decision.
- omi_audio_pcm_storage_stage_timeout_overshoot_seconds{stage} is observed only
for a child killed by its own timeout, as full stage wall time beyond the
granted timeout.
Both use fixed buckets (.005,.01,.05,.1,.25,.5,1,2), no per-request label, and
eight pre-created children without fabricated zero observations: 88 series per
pod with the pinned client, within the 96-series ceiling. Timestamps are taken
around the child only, so granted timeouts, subprocess arguments, the 0.4 s
budget, the 0.08 s decode reserve, the single slot, eligibility, byte-exact
verification, PCM fallback, existing counters and one timeout fallback are
unchanged. Observations are flushed after the codec slot is released, and the
disabled/ineligible/busy paths allocate nothing and observe nothing.
The diagnostics never feed the 0.5 s p99 guard, which keeps its buckets and its
population. Overshoot includes startup, cleanup and descheduling, so it is not a
pure process-start cost and not a wall-clock bound. Instrumentation alone cannot
pass the failed pusher canary; reactivation still needs Release authorization
and independent both-surface verification.
Verification: test_audio_pcm_storage.py 46 passed through the repository runner,
covering exactly-once observations on success/timeout/error, per-stage outcome
attribution, overshoot only on timeout, no observations on non-admitted paths,
pre-created children at zero, and unchanged returns/counters/fallback/slot
release. make preflight passed 37 checks.
Failure-Class: none
Review round 1 on #25414. The decode sample was appended after the byte comparison and SAVED_BYTES accounting, so the histogram included verification work that is not part of the child. Capture the end timestamp at the child's return or handled exception, before any comparison or accounting, and keep the deferred flush after slot release. The encode stage now stops its clock in the same place for a symmetric boundary. Measured with an injected clock whose comparison adds 0.30 s and whose saved-byte accounting adds 0.20 s: the previous head recorded a 0.55 s decode stage for a 0.05 s child, the corrected head records 0.05 s. The new deterministic regression fails on the previous head and passes here. Also correct the runbook: the per-surface scrape jobs are pusher-metrics and backend-listen-metrics, and the instrumentation cost is two timestamp reads per invoked child, not one. No change to subprocess arguments, forwarded timeouts, the 0.4 s budget, the 0.08 s reserve, the slot, eligibility, verification, fallback or custody path. Failure-Class: none
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.
Instrumentation only for SCA-2302. Sibling of the merged #25326 and #25357; no behavioural correction, no competing review.
Why
omi_audio_pcm_storage_secondstimes the whole optional step, so production data could not say which codec child consumed the time or how far a killed child overran its own granted budget. Release's historical 5-minute vectors put ~86% of admitted attempts inside the single(0.25, 0.5]bucket, which is exactly the resolution that query cannot provide.What changed
Three files, no behaviour change:
backend/utils/other/audio_pcm_storage.py— two diagnostic histograms and their observation points.backend/tests/unit/test_audio_pcm_storage.py— exactly-once and no-observation tests (10 new cases).backend/docs/runbooks/audio-durable-outbox.md— a diagnostics subsection with the read queries, costs and limits.omi_audio_pcm_storage_stage_secondsstage={encode,decode},child_result={success,timeout,error}subprocess.runthrough its return or handled exceptionomi_audio_pcm_storage_stage_timeout_overshoot_secondsstage={encode,decode}child_resultis that child's own outcome, not the call's terminal decision — asuccessencode on a call that later keeps PCM still reportssuccess. Both histograms use(.005,.01,.05,.1,.25,.5,1,2); eight children are pre-created and never observed at zero, soincrease()can see a first burst without a fabricated sample.Unchanged
Subprocess argument vectors,
_stage_timeout, the 0.4 s shared budget, the 0.08 s decode reserve, the single codec slot, eligibility bounds, the savings floor, byte-exact verification, PCM fallback,DECISIONS/INPUT_BYTES/SAVED_BYTES, the singlerecord_fallbackondeadline, and every custody/ACK/reader/object-lifetime semantic.omi_audio_pcm_storage_secondskeeps its buckets, and the p99 guard keeps its threshold and population. The timestamps are taken around the child only, after each granted timeout is already computed, so no forwarded timeout changes.Cost
88 new series per pod with the pinned
prometheus-client==0.21.1(8 children x 11 series: 8 buckets,+Inf,_sum,_count); 96 if a client also emits_created, which is the owner's ceiling. One clock read and one local tuple append per child that runs, plus a flush after the slot is released. Disabled, ineligible and busy calls allocate nothing and observe nothing. No per-request, content, size or account label.Limits, stated in the runbook
Overshoot includes startup, cleanup and thread descheduling, so it is neither a pure process-start cost nor a wall-clock bound. Stage series are empty while the compression flag is
falsebecause no child runs — absent data is not a fast encode. A missing observation, scrape gap, counter reset or silent target is UNKNOWN, never a zero pass. The whole-helper-minus-stage difference is an approximate diagnostic, not exact admitted overhead: the populations differ, the two histograms use different monotonic clocks, the flush is after slot release, and scrape-window boundaries differ.Merging or deploying this cannot pass the failed pusher canary and is not a reactivation, a qualification or a savings claim. Reactivation still needs separate scoped Release authorization plus independent both-surface verification.
Verification
backend/test.shwithBACKEND_UNIT_TEST_FILE_LIST=tests/unit/test_audio_pcm_storage.py: 46 passed, including all pre-existing codec, custody-frame and gapped-pack coverage.make preflight: 37 checks passed.New tests cover: encode+decode each observed once as
success; encode timeout with one overshoot and no decode observation; decode timeout reportingencode=success/decode=timeoutwith original PCM, one fallback and the slot released; a handled child error recorded aserrorwith no overshoot;not_smallerobserving only the successful encode; disabled/ineligible/busy observing nothing and leaving the live counters untouched; and the eight children existing at zero before any observation.Failure-Class: none