Skip to content

perf(firestore): re-graduate usage_month_cache, queue_age_sample_budget; singleton_loops 25% - #22929

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/fs-regress-levers
Oct 20, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/fs-regress-levers

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Re-graduate two proven Firestore read levers stuck below 100%, and restart singleton_loops at 25%. This changes only the FIRESTORE_READ_LEVERS literal: runtime_env _base.yaml → rendered runtime_env.yaml, listen + pusher dev/prod values, flag registry, and the two contract tests that pin the literal. Generated with avo/firestore-reads/set_levers.py as the complete 13-key literal.

Lever From → to Evidence Predicted reads/day saved
usage_month_cache 5 → 100 −45.0M/day absolute at 100% on 10-17 (loop readout readout-2026-10-17T20Z-absolute.json). It was flagged off 10-18 on an ambiguous backend-sync 5xx guard that stayed elevated with the lever at 0, then ran at 5% from 10-20 05Z with guards in band. ~35–39M. Its caller user_usage:get_monthly_usage_stats_since is 43.2M/day now (listen 33.1M + backend 10.1M, 24h to 10-20T17Z) vs ~4.9M/day at 100% on 10-17.
queue_age_sample_budget 5 → 100 At 5% since 10-20 05Z with no guard breach (WQ3, reviewed SAFE in #22142). Unknown until measured. Caller durable_queue_age:_sample_status_page is 46.8M/day visible (listen 40.3M, backend 6.5M) plus the sync services. It overlaps singleton_loops; never sum the two.
singleton_loops 0 → 25 At 100% on 10-17: −119M/day on its callers (ledger READOUT 2026-10-17T05:20Z). The 10-20T09Z flag-off (#22851) read acquired=0 / skipped_owner>0 on listen. fsr_admit returns skipped_owner for a recovery loop only while the tick key is live, and only an admission sets it, so the holder ran on backend-sync, whose lease counter #22118 hid (fixed in the companion PR). 25% first per the loop runbook until lease evidence is visible on every service. Unknown at 25%. Visible callers are 93M/day on listen + backend. Per-process cohorts mean savings scale with the cohort share.

Measurement line: the Firestore reads loop (avo/firestore-reads) grades each lever from the served revision. usage_month_cache is graded on absolute caller reads vs baseline-2026-10-20T05-00Z.json (get_monthly_usage_stats_since 1.24M reads/h on backend). Fleet total is progress.py HEADLINE (926M/day at 10-20T17Z).

Lane / contract

fs-regress (P1, two-lane rollout swarm 10-20), on behalf of the firestore-reads loop (work items WQ8, WQ3, WQ1 → WQ10).

Product invariants affected

INV-MEM-4: path match only. The lever literal appears in a file under the INV-MEM-4 glob; no memory promotion, consolidation or intake behavior changes. historical_scan_memo and the other memory-path levers keep their current values.

Verification

  • backend/test.sh with BACKEND_UNIT_TEST_FILE_LIST = test_render_backend_runtime_env.py, test_verify_pusher_config_references.py, test_firestore_read_levers.py, test_fsr_s2_singleton_loops.py, test_fsr_wq3_queue_age_budget.py, test_fsr_s4_caches.py: 70 passed (unit layer).
  • Precondition from the loop runbook for any singleton_loops enable: FSR_QUEUE_AGE_PUBLISHER=1 in prod listen values, and omi_queue_oldest_ready_age_seconds present on listen (200 series) and Cloud Run (490) at 10-20 18:30Z (in-cluster Prometheus, ro-prod).
  • Not run: any deploy. Live effect is measured by the loop after the lead's train.

Rollback

Each lever is its own kill switch. set_levers.py with the previous literal (usage_month_cache 5, queue_age_sample_budget 5, singleton_loops 0), or revert this commit. The loop's hourly verify flags a lever off on a 5xx or lease breach.

Deploy

FIRESTORE_READ_LEVERS train order: listen → pusher → Cloud Run (the Cloud Run candidate check compares listen/pusher env against main). Ship together with or after the companion sync-GMP scrape PR, so the singleton_loops lease gate can see every holder. Owned by the rollout lead.

Failure-Class: none

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

…et; singleton_loops 25%

FIRESTORE_READ_LEVERS literal only (runtime_env, listen + pusher values,
flag registry, two pinned contract tests):
- usage_month_cache 5 -> 100: measured -45.0M reads/day at 100% on 10-17;
  flagged off 10-18 on an ambiguous backend-sync 5xx guard that stayed
  elevated with the lever at 0. Its caller is 43.2M/day now (listen 33.1M,
  backend 10.1M, 24h to 10-20T17Z).
- queue_age_sample_budget 5 -> 100: 5% since 10-20 05Z with no guard breach.
- singleton_loops 0 -> 25: the 10-20T09Z "starvation" flag-off (#22851) read
  acquired=0 / skipped_owner>0 on listen; skipped_owner proves a live tick key,
  i.e. an admission on a holder whose lease counter #22118 hid. 25% first per
  the loop runbook until lease_1h is visible on every service.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level

Git-on-my-level commented Oct 20, 2026 •

Copy link
Copy Markdown
Member Author

Grok review (agentctl delegate, request_key fs-regress-review, selector family=grok) covering this PR and #22926: VERDICT: SAFE, no findings.

  • Literal: identical 13-key JSON in every declared location; only usage_month_cache, queue_age_sample_budget and singleton_loops change.
  • singleton_loops at 25 percent: non-cohort processes keep the unconditional callback() path, so there is no split-brain. Gauge withdrawal is process-local, so it cannot hide another pod's sample; the absent() / sample_unknown alert semantics hold.
  • queue_age_sample_budget at 100: early-stop publishes a lower bound that is already above the 21600s threshold. A capped scan sets sample_unknown. The 300s cache delays a crossing by at most one interval, inside the rule's 5m for.
  • usage_month_cache at 100: 60s TTL with a writer fence on update_hourly_usage. A Redis error falls through to Firestore. A missed invalidation under-counts usage, so it cannot deny transcription.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T19:47:42.580617Z fc2ccbb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level
Git-on-my-level merged commit 6f23b1f into main Oct 20, 2026
69 of 71 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/fs-regress-levers branch October 20, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant