Repository navigation
Keep server heartbeats responsive during expensive SQLite search - #5368
Closed
jonolee-kr wants to merge 1 commit into
Closed
jonolee-kr wants to merge 1 commit into
jonolee-kr wants to merge 1 commit into
Conversation
9 tasks
Contributor
|
This is an automated message. We have closed this pull request because it has been open for more than two weeks. |
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.
Draft for review. This branch requires rebasing and validation on current
mainbefore merge.The implementation was verified against the gorag checkout at
59a03819a, not current upstreammain.This draft contains the same 34 implementation files, with the unrelated Tasks Markdown commit excluded.
At publication, upstream
mainwas3aa5ef327093f2834f800370881ac0bed8f2d811, 1,581 commits ahead of this branch's base.GitHub reports merge conflicts with
main. The verified results below apply to the original checkout and require repetition after integration.Human comments
What was wrong
Thread search invokes synchronous better-sqlite3 and Drizzle operations on the main Node event loop.
An observed four-token FTS query took 102,177 ms while daemon heartbeat acknowledgements stopped and Connect disconnected.
Common tokens expand grouped and ranked results before limits apply. The original segment ranking also carries full message text through temporary tables.
Memory reclaim and I/O pressure can amplify that latency. Their exact contribution to the observed query remains unknown.
Related: #4413 and #5192.
Those issues include additional work outside this draft's scope. This draft does not auto-close either issue.
Investigation, benchmarks, resource proposals, and remaining synchronous paths: report.
What changed
The existing search UI already calls the affected SDK route and supplies an AbortSignal. No frontend change is required.
No server/daemon payload changes or public configuration knobs are introduced. No daemon protocol bump is required.
Existing SDK declaration automation changes are excluded. The report proposes resource budgets without applying them.
Merge blockers and limitations
main. Repeat correctness, lifecycle, build, and typecheck validation after integration.General timeline reads, thread-list metadata, foreign-key cascades, session pruning, legacy cleanup, and vacuum paths still contain synchronous operations.
SQLite interruption cannot preempt an uninterruptible kernel I/O operation. Worker isolation does not remove host memory or disk pressure.
No production deployment, restart, agent termination, or production limit change occurred.
How you verified
Validation used the original gorag checkout and disposable migrated databases. These results do not validate current upstream
main.Commands used, through Turbo with normal caching:
Validation commands ran in temporary resource scopes outside the production service. No forced rebuild flag was used.
Benchmark
The disposable workload used four common tokens across separate segments, 300 threads, and 60,000 messages with 4,096 padding characters.
Each variant received 20 warmups followed by 1,000 serial searches. Each search ran beside an unrelated health request and a 10 ms heartbeat timer.
The OS cache was warm and was not purged. These are origin-only loopback measurements, not production p99 or Connect round-trip measurements.
Search p99 worsened by approximately 77%. The result demonstrates event-loop isolation while leaving search tail latency unresolved.
The baseline used a 256 MiB cache and 1 GiB mmap ceiling. The reader used a 32 MiB cache and no mmap.
Sequential runs shared a host with other workloads. Those differences prevent causal attribution of the tail regression.
The benchmark predates final wrapper, listener, and deadline-entry corrections. The optimized query and worker isolation strategy remained the same.
A single startup-plus-search measurement was 949.7 ms with a warm OS cache. No cold-storage distribution was measured.