feat(performance): priority scheduler + read coalescing on the SQLite worker (0228 Phase 1)#279
Merged
crs48 merged 3 commits intoJun 26, 2026
Conversation
…dispatcher vs OPFS exclusivity) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… worker All storage work now funnels through one priority scheduler inside the SQLite worker (the single chokepoint both the main thread and data worker share): interactive reads drain ahead of queued writes, so a write/sync-apply burst can no longer starve a read — generalizing the 0227 head-of-line fix. Identical concurrent reads are coalesced into one execution. No parallelism is added (opfs-sahpool is single-connection by construction); this is pure ordering. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…r (0228) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
Preview removed for PR #279. |
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.
Implements Phase 1 of exploration 0228.
Context
The natural follow-up to 0227 was "can we have a pool of reader workers + a dispatcher?" The exploration found that the naive version is impossible: the web adapter's
opfs-sahpoolVFS holds exclusive file handles (a second worker on the same DB falls back to in-memory), and the replica-based version that would give true parallelism is gated on a benchmark proving CPU saturation and on enabling production cross-origin isolation (which has embedding risk). So the doc's recommended "do now" is a scheduler on the single worker — most of the felt latency win at a fraction of the cost.What landed
A priority scheduler + read coalescing inside
SQLiteWorkerHandler(the one chokepoint both the main thread and the data worker share, viaconnectPort):getSchedulerSnapshot()exposes queue depth for diagnostics.New
worker-scheduler.ts+ 7 deterministic tests proving the ordering/coalescing guarantees (these double as the exploration's "benchmark harness": an interactive read is provably served ahead of queued writes).@xnetjs/sqlitetypecheck + full unit suite green.Deliberately deferred (per the doc's own gating)
applyNodeBatchinto multiple transactions changes atomicity semantics; correctness-sensitive, wants its own change.getSchedulerSnapshot()hook exists; wiring the panel is a follow-up.The real worker path is exercised by the
editor-ux/capturee2e checks.🤖 Generated with Claude Code