Repository navigation
perf(server): keep worktree ensure work and index builds out of the query timeout - #28
Merged
Merged
Conversation
…e loop; add build lane Three changes keep worktree ensure work and index builds out of the query timeout: - _ensure_project_initialized now assembles the store view, overlay init, meta write, indexer, and first table touch inside one 'ensure_store' job on the worker pool, so first-touch LanceDB I/O on a large cache no longer freezes the event loop for every concurrent caller. - A foreground worktree search may spend at most LGREP_ENSURE_BUDGET_S (default 8.0s) making its trunk current: beyond the budget the remaining base work continues as the existing single-flight background continuation and the search answers from the partial index. - RuntimeSupervisor gains a dedicated build lane (LGREP_BUILD_MAX_THREADS, default 1) for index windows, pending-file computation, full reindexes, and prune sweeps, so builds cannot occupy the query threads sized by LGREP_WORKER_MAX_THREADS. runtime_job_finished events now carry the lane. Related to LGREP-25
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.
Related to LGREP-25
Concord work item: work-33fe59b853c9bd6785fbc58f (workflow.implementation, contract v1).
LGREP-24 evidence: 44/73 provider_timeout calls targeted Concord worktree paths, 45/73 overlapped a cache build, and 6 calls ran 41-71s where the tool-level wait_for never fired — synchronous first-touch LanceDB I/O on the event loop.
Changes
src/lgrep/server/lifecycle.py): the blocking half of_ensure_project_initialized— ChunkStore construction,for_checkoutoverlay init,write_project_meta, Indexer construction, forced first table touch — now runs as oneensure_storejob in the worker pool via a pure-assembly factory (_assemble_project_state). The app lock stays on the loop; concurrent callers are no longer frozen behind first-touch I/O._base_index_ready(wait=False)runs the staleness check plus at most one base window bounded byLGREP_ENSURE_BUDGET_S(default 8.0, documented belowLGREP_TOOL_TIMEOUT_S). Beyond the budget, or on a non-converging window, the remaining base work continues as the existing single-flight background continuation and the worktree search answers from the partial index.src/lgrep/server/runtime.py):RuntimeSupervisorgains a second executor (lgrep-build, sized byLGREP_BUILD_MAX_THREADS, default 1) for build kinds (index_window, compute_pending_files, index_all, startup_orphan_sweep, prune_orphans, prune_symbols, index_repo). Queries keepLGREP_WORKER_MAX_THREADS. Lane is derived from job kind viaBUILD_JOB_KINDS(an explicitlane=parameter can override);runtime_job_finishedevents and job snapshots carry the newlanefield; shutdown shuts down both executors.LGREP_ENSURE_BUDGET_SandLGREP_BUILD_MAX_THREADS; CHANGELOG entry.Verification
tests/test_lifecycle_ensure.py,tests/test_worktree_base_budget.py,tests/test_daemon_runtime.pyfail (12 failed) against the parent commit and pass (23 passed) with this change.