Skip to content

feat(daemon): macOS kqueue accept engine with blocking fallback - #6217

Merged
oferchen merged 1 commit into
masterfrom
feat/macos-kqueue-accept-engine
Jul 1, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/macos-kqueue-accept-engine

Conversation

@oferchen

@oferchen oferchen commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Task #457 (NACC-5). Adds a macOS kqueue/EVFILT_READ daemon accept engine behind the existing AcceptEngine trait (NACC-3), replacing a blocking accept()/sleep-poll on macOS with event-driven wait. Additive (+339/-4): the Single/Multi-listener engines are byte-identical; the only removed lines are a mut listeners→listeners signature tweak.

  • KqueueAcceptEngine reuses the existing fast_io::KqueueLoop safe wrapper (no new daemon FFI), registers all N listener fds (EVFILT_READ|EV_CLEAR, edge-triggered), and on poll() drain-accept()s a ready listener until WouldBlock (prevents dropped connections on a burst), resets accepted sockets to blocking, buffers surplus, returns one per poll.
  • Fallback: any kqueue init error → logs + returns the original listeners so build_accept_engine falls through to the existing single/multi engine. Accept never breaks.
  • Shutdown: 100ms bounded wait gives the shared loop the same signal-check cadence as the dual-stack engine; shutdown() idempotent. --max-connections admission + N-listener handling live in the shared loop body, untouched.

Verified on macOS aarch64 — real kqueue accept exercised: kqueue_engine 4 tests pass (client accept + blocking-reset via EVFILT_READ, Idle-parks-~100ms not busy-spin, 3-conn burst drained behind one notification, idempotent shutdown); full cargo test -p daemon --all-features 22 passed/9 ignored; clippy -D warnings, fmt, cargo doc gate all clean. Linux + blocking engines unchanged.

@github-actions github-actions Bot added the enhancement New feature or request label Jul 1, 2026
@oferchen
oferchen merged commit a93377f into master Jul 1, 2026
62 of 63 checks passed
@oferchen
oferchen deleted the feat/macos-kqueue-accept-engine branch July 3, 2026 03:40
oferchen added a commit that referenced this pull request Sep 8, 2026
…#7745)

The eleven docs that cite SIGNAL_CHECK_INTERVAL were line-accurate when
written, but the code moved twice since: PR #5908 lowered the
single-listener WouldBlock sleep from 500ms to 50ms and deleted the
constant, and PR #7681 replaced accept-side sleep-polling with a
readiness wait (poll(2) in PollAcceptEngine, kevent(2) behind the
opt-in macos-kqueue feature in KqueueAcceptEngine) in
server_runtime/accept_engine.rs.

Bring the living documents back in line with the tree:

- kqueue-pipeline-audit: mark the two daemon-accept surface rows
  migrated (KQ-S.1 landed via #6217/#7681) instead of describing the
  deleted sleep-poll loops as the current implementation.
- daemon-tpc-benchmark-plan: bound SIGTERM-to-drain latency by the
  accept engine's 50ms/100ms signal-check cadence, and mark tracker
  #1683 completed.
- daemon-event-loop-multiplexing: add a status note to the follow-up
  list and tick #1683, which #5908/#7681 closed.
- daemon-thread-per-connection-scalability: mark tracker #1683
  completed in the references list.
- dis-4a, dis-3, daemon-coldstart-profile, daemon-coldstart-rebench:
  record that DIS-4.a R1 has since landed, next to the sections that
  rank it as the top open bottleneck; retarget the DIS-2 file index
  entry that still pointed the constant at listener.rs.

The audit bodies keep their historical line citations: they describe
the tree that was measured. daemon-thread-per-connection.md,
async-daemon-listener.md (pinned 'Last verified: 2026-05-01'), and
daemon-async-listener-rfc.md are left untouched as dated snapshots.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant