Skip to content

config(ops): backend-sync max_instances 40 -> 30 (margin G1, gated) - #24303

Merged
Git-on-my-level merged 2 commits into
mainfrom
perf/backend-sync-cap-30
Nov 1, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
perf/backend-sync-cap-30

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Problem and change

backend-sync is pinned at its service cap of 40 instances (syncdiet, 2026-11-01): bursty hot instances
keep the autoscaler at the cap, so the instance saving from #24264 (hourly re-poll of long-stuck
custody deferrals, ~45k fewer sync-jobs/run deliveries per hour) only lands through a lower cap.

This PR changes the ops source of truth only: backend/deploy/ops/prod.yaml
cloud_run.backend-sync.max_instances 40 → 30 (min stays 5), and pins
test_cloud_run_rightsizing_pins.py to (5, 30).

Merging applies nothing. config_train.yml is workflow_dispatch only. Backend deploys
live-resolve the sync maxScale, so no train reverts the live value either way.

Expected: −10 instances × 24 h × $0.1789/inst-h ≈ −$43/day (syncdiet's instance-based rate),
visible only after the apply.

Apply (lead, after the gates)

Gates (syncdiet §1, lead ruling 92aecb), each held for 1 h:

  1. perf(enrichment): poll long-stuck custody deferrals hourly #24264 has served ≥ 7 h. It is in train fbc7973 (image digest d1024bc3e84f, serving since
    2026-11-01 19:11:16Z), so the earliest apply time is 02:11Z 11-02.
  2. sync-jobs-fresh task_attempt_delays p95 < 2 s.
  3. backend-sync request latency p95 ≤ 12 s.
  4. backend-sync max_request_concurrencies p95 ≤ 13.5.
  5. The size-121 ({"status":"deferred"}) share of sync-jobs/run 200s < 10%.

Read-only checker (ro-prod, aggregates only), held outside the repo:
python3 -I /Volumes/Ephemeral/scratch/margin20/g1_gates.py --census. Baselines by the same
method: gate 4 = 13.4 (16–17Z 11-01), 17.4 (18–19Z), 18.7 (19:28–20:28Z). Gate 4 may not clear
on a Sunday evening.

Apply, canonical path:

gh workflow run config_train.yml -R BasedHardware/omi -f environment=prod -f mode=plan -f ref=main
# plan must show only: backend-sync run.googleapis.com/maxScale 40 -> 30
gh workflow run config_train.yml -R BasedHardware/omi -f environment=prod -f mode=apply -f ref=main

Break-glass equivalent: infra/rollout/bin/cr_apply.sh backend-sync --max=30. The service-level
annotation is the authoritative cap (the sentinel reads it), and --max creates no revision.

The sentinel's hard-coded sync target (sentinel/scripts/cloud_run_state.py TARGETS) still reads
80, which is already stale against live 40. The lead updates it to 30 at apply.

Rollback

cr_apply.sh backend-sync --max=40, which takes minutes. Then revert this PR (or set 40) so the
next config-train keeps it. Roll back on any of: attempt-delay p95 > 2 s for 15 min,
latency p95 > 12 s for 15 min, or sync-jobs-fresh depth above 2× its pre-apply hour.

Relation to #23973

#23973 edits the same key. Its body describes 5/50 → 3/20, but main is now 5/40, and the author holds
it until fresh qualification. It must not merge as-is. If it is revived after this PR, rebase it
onto 5/30. G1 does not depend on it.

Validation

backend/test.sh with BACKEND_UNIT_TEST_FILE_LIST = test_cloud_run_rightsizing_pins.py,
test_config_train.py, test_drift_check.py: 88 passed (4 + 52 + 32), run through bin/omi-heavy with
no GCP credentials. The bounded pre-push gate passed.

Owns: this PR only. Review: Luna, via review.sh.

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Source change only. The config-train is workflow_dispatch, so merging this
applies nothing; the lead dispatches config_train.yml (prod, plan then apply)
after #24264 has served 7h and syncdiet's gates hold for 1h. Backend deploys
live-resolve the sync maxScale, so a train cannot revert the applied value.

Pins test_cloud_run_rightsizing_pins.py to (min 5, max 30). Rollback: 40.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

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 ⚠️ Failed 2026-11-01T20:39:19.750358Z
We couldn’t complete this review. Comment @codex review to try again.
557a7d6 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Confidence score: 3/5

  • The value in backend/deploy/ops/prod.yaml is applied to every prod config-train apply, so unrelated changes can also hit the build_plan checks intended for the gated lead dispatch. Scope it to that dispatch path.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/deploy/ops/prod.yaml">

<violation number="1" location="backend/deploy/ops/prod.yaml:78">
P1: This value is applied by every prod config-train apply, not only the one the lead dispatches after the gates. `build_plan` checks every service in the file, so any unrelated apply (for example a queue rate change) will set backend-sync to max 30 before the 7h/1h gates hold. Keep `max_instances: 40` in this PR and change it to 30 only in the gated apply.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

# custody deferrals) has served 7h and the syncdiet gates hold for 1h. Merging
# this does not apply it; the lead dispatches the config-train after the gates.
# Rollback: 40 (floor remains 5).
max_instances: 30

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: This value is applied by every prod config-train apply, not only the one the lead dispatches after the gates. build_plan checks every service in the file, so any unrelated apply (for example a queue rate change) will set backend-sync to max 30 before the 7h/1h gates hold. Keep max_instances: 40 in this PR and change it to 30 only in the gated apply.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/deploy/ops/prod.yaml, line 78:

<comment>This value is applied by every prod config-train apply, not only the one the lead dispatches after the gates. `build_plan` checks every service in the file, so any unrelated apply (for example a queue rate change) will set backend-sync to max 30 before the 7h/1h gates hold. Keep `max_instances: 40` in this PR and change it to 30 only in the gated apply.</comment>

<file context>
@@ -71,8 +71,11 @@ cloud_run:
+    # custody deferrals) has served 7h and the syncdiet gates hold for 1h. Merging
+    # this does not apply it; the lead dispatches the config-train after the gates.
+    # Rollback: 40 (floor remains 5).
+    max_instances: 30
     min_instances: 5
   backend-sync-backfill:
</file context>
Suggested change
max_instances: 30
max_instances: 40

@Git-on-my-level
Git-on-my-level merged commit 200ed7e into main Nov 1, 2026
59 checks passed
@Git-on-my-level
Git-on-my-level deleted the perf/backend-sync-cap-30 branch November 1, 2026 22:07
Git-on-my-level added a commit that referenced this pull request Nov 2, 2026
… G1) (#24329)

## Problem and change

#24303 set `backend/deploy/ops/prod.yaml`
`cloud_run.backend-sync.max_instances` to 30 for a gated apply. The lead
held the apply at 02:11Z, and it never ran: live is still 40. Leaving 30
in source means the next config-train
dispatch, for any reason, would apply it without the gates.

This PR puts the source back to 40 and the
`test_cloud_run_rightsizing_pins.py` pin back to (5, 40). Live does not
change.

## Why the cap is dropped, not delayed (measured, ro-prod Cloud
Monitoring, backend-sync)

| hour | requests/h | avg instances | max_request_concurrencies p95 |
latency p95 |
|---|---:|---:|---:|---:|
| 16–17Z 11-01 (before #24264) | 133.4k | 39.9 | 13.4 | 8.82 s |
| 01–02Z 11-02 | 93.1k | 33.3 | 18.4 | 12.01 s |

#24264 removed the short (~2.4 s) deferred re-polls, so the remaining
requests are long sync jobs. In-flight per
instance rose while instances fell 40 → 33 on their own. At concurrency
p95 18–20 of `containerConcurrency` 20, a cap of
30 would queue work rather than trim idle capacity. The instance saving
the cap targeted has already happened.

## Validation

`backend/test.sh` with `BACKEND_UNIT_TEST_FILE_LIST` =
test_cloud_run_rightsizing_pins.py, test_config_train.py,
test_drift_check.py: 88 passed (4 + 52 + 32), via `bin/omi-heavy`, with
no GCP credentials. The bounded pre-push gate passed.

Rollback: revert this PR. Applying nothing either way: config-train is
`workflow_dispatch` only.

🤖 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/24329?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/24329?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24329&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. -->
MichaelC001 pushed a commit to MichaelC001/omi that referenced this pull request Nov 2, 2026
… G1)

BasedHardware#24303 set the source cap to 30 for a gated apply that never happened (lead
held it at 02:11Z). After BasedHardware#24264 removed the short deferred re-polls, sync runs
long jobs at max_request_concurrencies p95 18-20 of containerConcurrency 20 on
~33 instances, so a lower cap would queue work rather than trim idle capacity.
Live stays 40; this puts the source back so no config-train dispatch can apply
30 without the gates. Pins test_cloud_run_rightsizing_pins.py to (5, 40).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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