Repository navigation
perf(quota): skip redundant quota_snapshots from idle connections (#4438) - #4565
Merged
Merged
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Jun 21, 2026
Merged
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.
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.
Closes #4438
Problem
The quota cache background refresh ticks every 60s and
setQuotaCachepersisted aquota_snapshotsrow 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
setQuotaCachenow captures the prior cache entry before overwriting and gates eachsaveQuotaSnapshotcall through a new pure helperquotaSnapshotChanged(prior, windowKey, remainingPercentage, exhausted):remaining_percentageoris_exhaustedTrend/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/lastActivityAtleft as a follow-up.