Skip to content

docs(design): DASYNC.2 tokio async listener bridge design (#3983) - #5628

Merged
oferchen merged 1 commit into
masterfrom
docs/dasync-2-tokio-async-listener-design
Jun 10, 2026
Merged

oferchen merged 1 commit into
masterfrom
docs/dasync-2-tokio-async-listener-design

Conversation

@oferchen

@oferchen oferchen commented Jun 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Specifies the bridge from tokio::net::TcpListener::accept to the existing synchronous handle_session() worker; DASYNC.3 is a wiring change, not greenfield.
  • Replaces the drop-on-accept closure at crates/daemon/src/daemon.rs:411-418 with a spawn_blocking + handle_session dispatch gated by a tokio::sync::Semaphore sized to --max-connections.
  • Eager @ERROR: max connections (N) reached -- try again later refusal preserves upstream wire bytes; locks bridge contract for TLS / LSM / cap-admission overlays.

Document

docs/design/dasync-2-tokio-async-listener.md covers:

  • Architecture (tokio accept -> permit acquisition -> into_std() -> spawn_blocking(handle_session)).
  • Seven key invariants (bounded blocking pool, semaphore gating, OwnedSemaphorePermit outlives worker, panic isolation parity).
  • Back-pressure model with three regimes (under cap, at cap eager refuse, sustained saturation -> kernel backlog).
  • Bridge to TLS (handshake stays inside spawn_blocking), LSM-CAP (startup, unchanged), LSM-SECCOMP (per-worker prologue), Landlock (transfer prologue, unchanged), --max-connections admission move.
  • DASYNC.3 sub-task ladder (3.a skeleton -> 3.b semaphore -> 3.c panic isolation -> 3.d pool sizing -> DASYNC.5 bench -> DASYNC.4 flag decision).
  • Test plan (unit + integration + bench).
  • Rollback criteria (opt-in until N>=5K parity, wire interop green across rsync 3.0.9 / 3.1.3 / 3.4.1 / 3.4.2 / 3.4.4, two release cycles green CI).
  • Risks and open questions (spawn_blocking overhead at N=1K, pool size vs cap, single vs dual feature flag, dual-stack accept).

Cross-references

  • DASYNC.1 audit doc (PR docs(design): DASYNC.1 daemon accept loop + worker spawn inventory #5624) supplies the file:line anchors this design wires.
  • [[project_daemon_10k_conn_ceiling]] - saturation problem this solves.
  • [[project_no_async_threaded_only]] - data path stays sync; only accept becomes async.
  • [[project_russh_spawn_blocking_ceiling]] - analogous bridge pattern; shared ceiling.
  • [[project_daemon_max_connections_v062]] - DMC series; @ERROR: refusal byte format.

Test plan

Specifies the bridge from tokio::net::TcpListener::accept to the
existing synchronous handle_session() worker. The hybrid skeleton at
crates/daemon/src/async_listener.rs:73 already accepts streams; this
design replaces the drop-on-accept closure at daemon.rs:411-418 with
a spawn_blocking + handle_session dispatch gated by a
tokio::sync::Semaphore sized to --max-connections.

Covers architecture, key invariants, back-pressure model (eager
@error refusal preserving upstream wire bytes), bridge to existing
TLS / LSM / cap-admission overlays, sub-task ladder for DASYNC.3,
test plan, rollback criteria, and cross-references to DASYNC.1.
@oferchen
oferchen force-pushed the docs/dasync-2-tokio-async-listener-design branch from d838c37 to 41be7b5 Compare June 10, 2026 20:11
@oferchen
oferchen merged commit 6bce854 into master Jun 10, 2026
8 checks passed
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jun 10, 2026
@oferchen
oferchen deleted the docs/dasync-2-tokio-async-listener-design branch June 11, 2026 03:11
oferchen added a commit that referenced this pull request Aug 24, 2026
…ener-design

docs(design): DASYNC.2 tokio async listener bridge design (#3983)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant