Skip to content

perf(quota): skip redundant quota_snapshots from idle connections (#4438) - #4565

Merged
diegosouzapw merged 1 commit into
release/v3.8.33from
fix/4438-quota-snapshot-dedup
Jun 21, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.33from
fix/4438-quota-snapshot-dedup

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Closes #4438

Problem

The quota cache background refresh ticks every 60s and setQuotaCache persisted a quota_snapshots row for every window of every connection regardless of whether the value changed. With 273 connections (83 idle), this generated 400K–545K rows/day of near-duplicate data.

Fix

setQuotaCache now captures the prior cache entry before overwriting and gates each saveQuotaSnapshot call through a new pure helper quotaSnapshotChanged(prior, windowKey, remainingPercentage, exhausted):

  • writes when there is no prior entry (first observation / baseline row)
  • writes when the window was never seen before
  • writes on any real change to remaining_percentage or is_exhausted
  • skips when both are unchanged (idle connection no-op refresh)

Trend/time-series data is preserved (every change still lands a row); only redundant idle rows are dropped.

Test (Hard Rule #18 — TDD)

New tests/unit/quota-cache-snapshot-dedup-4438.test.ts (5 cases). Confirmed RED before the helper existed → GREEN after (5/5). typecheck:core clean, eslint clean on touched files.

Scope

Surgical: src/domain/quotaCache.ts (pure helper + one gate) + test + CHANGELOG. No schema/migration change; batching/lastActivityAt left as a follow-up.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@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.

@diegosouzapw
diegosouzapw merged commit cf6546e into release/v3.8.33 Jun 21, 2026
3 checks passed
@diegosouzapw
diegosouzapw deleted the fix/4438-quota-snapshot-dedup branch June 21, 2026 21:28
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
…eaper-inference#4438) (cheaper-inference#4565)

Closes cheaper-inference#4438. Dedupes quota_snapshots writes for idle connections via pure quotaSnapshotChanged() gate. TDD 5/5. Admin-merged over a pre-existing, unrelated base red (model-lockout-max-cooldown.test.ts 'markAccountUnavailable local 404 ... maxCooldownMs', from cheaper-inference#4530 incomplete wiring) proven to fail on release/v3.8.33 HEAD without this change.
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