Repository navigation
perf(kv): bound scans and deduplicate cache writes - #1042
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Pigbibi
marked this pull request as ready for review
November 1, 2026 20:07
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.
AI assistance
Codex (user-requested sol). Existing four drafts originally used DeepSeek; this revision is implemented and verified by Codex.
What changed
Persist a 100-attempt UTC-day List budget in the existing serialized directory; change default reconciliation from six hours to one day; preserve immediate key registration. Serialize semantic current-strategies cache writes across isolates using a persisted digest and the existing 15-minute keep-alive. Fix in_progress for a complete snapshot with a pending cursor. Retain receiver-first compatibility and loud storage/quota errors.
Why
Reduce repeated Worker computation and KV operations without changing authorization or business decisions.
How verified
Directory and cache regression suites PASS: 288 cron ticks => 1 List/1 mirror put; 100 simultaneous refreshes => 1 cache put; Worker bridge, restart, rotation, real changes, failed-write retry and legacy receiver covered. Python: 1067 tests OK (10 skipped) in an isolated checkout of this head. Generated config/display/runtime validation, frontend build/operations tests, syntax and documentation style PASS. The CI JS sequence was executed in parts: Node 24 rejected the CI's legacy flag, so remaining commands used Node 22. One UX1 demo test cannot determine its listener because lsof is unavailable; other executed JS commands passed. In a multi-repository layout, three compatibility subcases fail on both main and this head because the sibling QuantAIService changes discovery; the isolated suite passes.
Daily KV estimate
Normal single-page steady case: 1 List/day (0.1% of Free), plus admin/migration pages, with 100 attempts/day (10%) enforced by this owner. Cache/mirror writes <=97/day plus actual cache content changes, other record writes and new-key mirrors. If those extra writes are B, QRS is <=97+B/day; other namespaces historically average 88/day, giving a planning total <=185+B/day. Reserving the entire historical QRS mean (529.33) as B gives a deliberately conservative planning scenario of 626.33 QRS writes/day and 714.33 account writes/day (71.43%). This is not a production measurement or a bound on mutation bursts; peak writes can still exceed 1000/day.
Free account-wide limits: 1,000 writes/day and 1,000 Lists/day, resetting at 00:00 UTC. Cloudflare KV pricing. Estimates assume the audit workload; no deployment or post-change production measurement has occurred. Bulk writes still count per key.
Risk
High: Worker and existing DO paths. Out-of-band discovery may lag up to 24 hours by default; indexed ingress remains immediate. New list-budget exhaustion remains an explicit outage until UTC reset +60s. No authority/freshness checks, protected labels, deployment settings or bindings are weakened. No merge or deployment.