Skip to content

fix(index): wrap chunk_file in spawn_blocking to unblock tokio runtime#2964

Merged
bug-ops merged 1 commit intomainfrom
2954-chunk-file-spawn-blocking
Apr 13, 2026
Merged

fix(index): wrap chunk_file in spawn_blocking to unblock tokio runtime#2964
bug-ops merged 1 commit intomainfrom
2954-chunk-file-spawn-blocking

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Apr 13, 2026

Summary

  • chunk_file() (tree-sitter AST parsing) was called synchronously inside async fn index_file(), blocking tokio workers and causing ~1000% CPU with buffer_unordered(2) during startup indexing
  • Wrapped the call in tokio::task::spawn_blocking; JoinError is mapped to IndexError::Other
  • Added async unit test index_file_spawn_blocking_dedup_path covering the spawn_blocking dispatch and dedup idempotency path (no Qdrant required)

Test plan

  • cargo nextest run -p zeph-index — 103/103 pass
  • cargo clippy --workspace -- -D warnings — clean
  • cargo +nightly fmt --check — clean
  • Full workspace: 7923 tests pass

Closes #2954

CPU-intensive tree-sitter AST parsing in chunk_file() was called directly
inside async index_file(), blocking tokio workers and causing ~1000% CPU
with buffer_unordered(2) during startup indexing.

Wrap the call in tokio::task::spawn_blocking with JoinError mapped to
IndexError::Other. Add async unit test covering the spawn_blocking dispatch
and dedup idempotency path.

Closes #2954
@github-actions github-actions Bot added bug Something isn't working rust Rust code changes size/M Medium PR (51-200 lines) and removed bug Something isn't working labels Apr 13, 2026
@bug-ops bug-ops merged commit 2eb49c1 into main Apr 13, 2026
30 checks passed
@bug-ops bug-ops deleted the 2954-chunk-file-spawn-blocking branch April 13, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(index): chunk_file blocks tokio worker during project indexing causing ~1000% CPU

1 participant