docs(design): daemon async accept loop with sync transfer workers#3649
Merged
Conversation
Specifies a hybrid model where a tokio async accept loop hands off accepted connections to a fixed-size pool of synchronous worker threads via a bounded channel. Transfer state machine and wire format are unchanged; the design only replaces the accept-and-dispatch layer. Tracking #1674. References #1591 (async-channel abstraction), #1934/#1935 (async-daemon feature gate), #2052 (TLS termination).
3 tasks
oferchen
added a commit
that referenced
this pull request
May 5, 2026
…3652) Cross-cutting follow-up to PRs #3645 (buffer pool sharding) and #3649 (daemon async accept). Both designs default to num_cpus * 2 which underutilizes I/O-bound workloads and oversubscribes CPU-bound ones. This note specifies a feedback-driven adaptive sizer with a PI-controller in the [60%, 85%] utilization band, hard bounds [max(2, n/2), n*4], 5 s grow / 30 s shrink cadence, and a daemon config knob "transfer-worker-threads = adaptive | <int>" plus an OC_RSYNC_ADAPTIVE_THREADS env-var disable for the first release. Zero wire-protocol impact.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
) Specifies a hybrid model where a tokio async accept loop hands off accepted connections to a fixed-size pool of synchronous worker threads via a bounded channel. Transfer state machine and wire format are unchanged; the design only replaces the accept-and-dispatch layer. Tracking #1674. References #1591 (async-channel abstraction), #1934/#1935 (async-daemon feature gate), #2052 (TLS termination).
oferchen
added a commit
that referenced
this pull request
May 18, 2026
…3652) Cross-cutting follow-up to PRs #3645 (buffer pool sharding) and #3649 (daemon async accept). Both designs default to num_cpus * 2 which underutilizes I/O-bound workloads and oversubscribes CPU-bound ones. This note specifies a feedback-driven adaptive sizer with a PI-controller in the [60%, 85%] utilization band, hard bounds [max(2, n/2), n*4], 5 s grow / 30 s shrink cadence, and a daemon config knob "transfer-worker-threads = adaptive | <int>" plus an OC_RSYNC_ADAPTIVE_THREADS env-var disable for the first release. Zero wire-protocol impact.
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
Adds
docs/design/daemon-async-accept-sync-workers.md(TODO #1674), a 624-line design note specifying a hybrid execution model for the rsync daemon at high concurrency: a tokio async accept loop hands off accepted connections to a fixed-size pool of synchronous worker threads via a bounded channel. Transfer state machine and wire format are unchanged; the design only replaces the accept-and-dispatch layer.Key sections
crates/daemon/src/daemon/sections/server_runtime/accept_loop.rsandconnection.rs.serve_connections,run_single_listener_loop,run_dual_stack_loop,spawn_connection_worker, withcatch_unwindpanic isolation.tokio::task::spawn_blocking, explicit-join pool) with reasoning.std::threadpool (Strategy A), reusing the channel abstraction documented indocs/design/async-channel-abstraction.md.num_cpus * 2default, configurable viatransfer-worker-threadsdirective.listen_backlogandnet.core.somaxconn.asyncfeature incrates/daemon/Cargo.toml, opt-in viause-async-listener = true, default off until benchmarked.catch_unwind, drop stream, release accounting, loop. Pool is not poisoned.somaxconndocumentation, drop-counter metric, stuck-worker watchdog.Wire-compat invariants confirmed
Handshaking -> Authenticating -> Listing | Transferring -> Completed | Failedincrates/daemon/src/daemon/session_registry.rs) runs in the samehandle_sessionbody, byte-for-byte the same code path.crates/protocol,crates/engine,crates/checksums,crates/transfer, orcrates/coreare implied by this design.Test plan
docs/design/async-channel-abstraction.md.