Make npackd handle connections concurrently - #9
Merged
Merged
Conversation
Make the recursive dependency-install future Send (Pin<Box<dyn Future + Send + 'a>>) so each accepted npackd connection can be handled on its own tokio::spawn task instead of serially. Verified with a real concurrency test (two simultaneous ListInstalled calls against run_daemon over a real socket) and manually against two simultaneous real GetPackage network calls, which completed in ~11s total instead of ~20s sequential. GetTransaction/CancelTransaction and progress-event streaming remain future work; a safe CancelTransaction needs a real cooperative checkpoint in the install path rather than raw task abortion, which risks leaving the store half-installed. Co-Authored-By: Claude Sonnet 5 <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
Send(Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>) sonpackdcantokio::spawna task per accepted connection instead of handling them serially.tokio::spawnboundary.Test plan
cargo fmt --all -- --checkcargo clippy --all-targets --all-features(no warnings)cargo test(47 passing, including a newdaemon_serves_concurrent_connectionstest that runs the realrun_daemonloop and issues two simultaneousListInstalledcalls over a real socket)GetPackagecalls against npack's own live Nostr/Blossom release completed in ~11s total instead of ~20s sequential, with responses arriving out of order — confirming genuine concurrent handling, not just non-blocking acceptNot in this PR
GetTransaction/CancelTransactionand progress-event streaming remain future work (tracked in the roadmap). A safeCancelTransactionneeds a real cooperative checkpoint in the install path (e.g. between packages in a dependency closure) rather than raw task abortion, which risks leaving the store half-installed — that's a larger, separate change.🤖 Generated with Claude Code