Skip to content

docs(audits): scope daemon thread-per-connection ceiling and admission gap (#1673) - #4023

Merged
oferchen merged 1 commit into
masterfrom
docs/daemon-thread-scalability-1673
May 14, 2026
Merged

oferchen merged 1 commit into
masterfrom
docs/daemon-thread-scalability-1673

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Audit crates/daemon/src/daemon/sections/server_runtime/ (accept_loop, connection, connection_counter, listener, workers) against upstream socket.c:start_accept_loop (lines 533-624) and clientserver.c:744-756.
  • Add docs/audits/daemon-thread-per-connection-1673.md: a single-page audit covering thread creation cost, stack budget (Rust default 2 MiB, glibc reserves 8 MiB; no thread::Builder::stack_size anywhere in the daemon), admission control (listen backlog at accept_loop.rs:139, no daemon-level concurrency cap), worker lifecycle (joined not detached; O(n) reap walk per accept), shared state, and the fork-vs-thread tradeoff.
  • Threshold table: 100 conns fine, 1 k marginal (first hits RLIMIT_NOFILE default 1024 and pays O(n) reap), 10 k broken (RLIMIT_NPROC, OOM, clone3: EAGAIN).
  • Mitigations ranked by cost (admission cap, smaller stack, bounded pool, async listener, fork).
  • One concrete recommendation: enforce a daemon-level max connections admission cap that reads the already-wired ConnectionCounter::active() (connection_counter.rs:32-35, currently #[allow(dead_code)]) before thread::spawn at connection.rs:121 and returns @ERROR: max connections (N) reached matching upstream clientserver.c:752. Smallest change, prerequisite for every other mitigation.
  • Cross-references existing docs/audits/daemon-thread-per-connection.md, docs/audits/daemon-thread-per-connection-scalability.md, the async listener RFC (Accept quoted fallback override values #1934), the benchmark task (Optimize rolling checksum bulk rolls #1933), and the completed chroot audit (Fix cross-platform release packaging #2129).

Docs-only. No code changes.

Test plan

  • cargo fmt --all -- --check (no source changed, expected pass)
  • cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings (no source changed, expected pass)
  • Verify all file:line citations resolve against current master

…n gap (#1673)

Distil the existing thread-per-connection analysis into a single-page
audit with a concrete threshold table (100/1k/10k) and one
recommendation: a daemon-level max-connections admission cap that reads
the already-wired ConnectionCounter before thread::spawn and returns
upstream's @error: max connections (N) reached.
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 14, 2026
@oferchen
oferchen merged commit 7956eeb into master May 14, 2026
8 checks passed
@oferchen
oferchen deleted the docs/daemon-thread-scalability-1673 branch May 14, 2026 14:57
oferchen added a commit that referenced this pull request May 18, 2026
…n gap (#1673) (#4023)

Distil the existing thread-per-connection analysis into a single-page
audit with a concrete threshold table (100/1k/10k) and one
recommendation: a daemon-level max-connections admission cap that reads
the already-wired ConnectionCounter before thread::spawn and returns
upstream's @error: max connections (N) reached.
oferchen added a commit that referenced this pull request Aug 24, 2026
…n gap (#1673) (#4023)

Distil the existing thread-per-connection analysis into a single-page
audit with a concrete threshold table (100/1k/10k) and one
recommendation: a daemon-level max-connections admission cap that reads
the already-wired ConnectionCounter before thread::spawn and returns
upstream's @error: max connections (N) reached.
oferchen added a commit that referenced this pull request Aug 24, 2026
…n gap (#1673) (#4023)

Distil the existing thread-per-connection analysis into a single-page
audit with a concrete threshold table (100/1k/10k) and one
recommendation: a daemon-level max-connections admission cap that reads
the already-wired ConnectionCounter before thread::spawn and returns
upstream's @error: max connections (N) reached.
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