Skip to content

perf: check an account's models concurrently in /internal/accounts - #175

Merged
CMGS merged 1 commit into
fix/model-cooldownfrom
review/model-cooldown
Oct 27, 2026
Merged

CMGS merged 1 commit into
fix/model-cooldownfrom
review/model-cooldown

Conversation

@CMGS

@CMGS CMGS commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Review follow-up to #174, targeting its branch. Merge it into fix/model-cooldown before #174 is squash-merged.

Change

With per-model health, /internal/accounts checks one health key per (account, served model) instead of one per account, and it awaited each lookup in sequence. On a Redis-backed fleet, that turns one round trip per account into one per served model. This PR joins each account's lookups. The behavior and the response shape are unchanged.

Measured against a local Redis 7, using the live-matrix config (25 accounts, 102 models), median of 5 calls with the health cache expired between calls:

build /internal/accounts
#174 (2741be3) 17.6–17.9 ms
this PR 7.2–7.4 ms

It also rewraps the HealthStore paragraph in docs/architecture.md, where one line ran past 100 columns.

Review of #174 (no other change needed)

  • Call sites. Every HealthStore call site uses the per-model key: selection, failover, success and failure recording, the realtime handshake and the admin view. Realtime only selects; it records no health.
  • Admin view filter. It matches AccountPool::serves: protocol strings compare exactly (Protocol::from_wire has no aliases), and the provider check uses the same config fields.
  • Hot path. Each request makes one short key String per candidate account and one per recorded success. join_all already allocates. Avoiding the strings would mean a nested-map health store and a new trait shape, which is too much for tens of nanoseconds.
  • Ownership. note_failure moves the key into the alert after the decision borrows it, so there is no clone.
  • Comments. None added. The PR's own net is ±0.
  • Size. fix: cool an account down per served model, not for every model it serves #174 against main: production +25, tests +129. This PR adds 8 production lines.

Gates

Per-model health turned the view's one lookup per account into one per
served model, awaited in sequence: 25 accounts and 102 models took 17.7 ms
against a local Redis, 7.3 ms with each account's lookups joined. Also
rewraps the HealthStore paragraph in architecture.md.
@CMGS
CMGS merged commit 986166a into fix/model-cooldown Oct 27, 2026
2 checks passed
@CMGS
CMGS deleted the review/model-cooldown branch October 27, 2026 02:14
CMGS added a commit that referenced this pull request Oct 27, 2026
…rves (#174)

* fix: cool an account down per served model, not for every model it serves

A model-level upstream refusal (OpenRouter's peak-load refusals for one model) tripped the account's cooldown, so a single-account pool answered no healthy upstream for every other model too. The failure streak and cooldown are now keyed by account and served model; /internal/accounts lists the cooling models.

* test: cover an in-stream refusal on a variant-served model in the per-model cooldown test

* review: keep the prompt_cache assignment where it was in SelectAccount

* perf: check an account's models concurrently in /internal/accounts (#175)

Per-model health turned the view's one lookup per account into one per
served model, awaited in sequence: 25 accounts and 102 models took 17.7 ms
against a local Redis, 7.3 ms with each account's lookups joined. Also
rewraps the HealthStore paragraph in architecture.md.
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