perf: use spawn_blocking instead of OS threads for per-connection handling#834
Draft
perf: use spawn_blocking instead of OS threads for per-connection handling#834
Conversation
…dling Replaces std::thread::Builder::new().spawn() with runtime_handle.spawn_blocking() in both control and trace listener loops. This reuses tokio's bounded blocking thread pool instead of creating an unbounded number of OS threads (one per git invocation). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The runtime_handle parameter is only used in the Unix path (spawn_blocking) but not in the Windows fixed-worker-pool path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…exit When the tokio runtime drops, it blocks waiting for all in-flight spawn_blocking tasks. If a handler is blocked reading from a slow git process, this could hang the daemon process indefinitely. Cap the wait at 5 seconds so the process exits cleanly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
spawn_blockingfor per-connection handling: Replacesstd::thread::spawnwithtokio::spawn_blockingin both control and trace listener loops (Unix path). This reuses tokio's bounded blocking thread pool instead of creating unbounded OS threads per git invocation.runtime.shutdown_timeout(5s)afterrun_daemonreturns so in-flightspawn_blockinghandlers don't stall process exit indefinitely.Test plan
cargo clippyclean on all platforms (including Windows unused variable fix)cargo fmtclean🤖 Generated with Claude Code