Skip to content

feat(fast_io): macOS kqueue event loop primitive (#1385)#4294

Merged
oferchen merged 1 commit into
masterfrom
feat/macos-kqueue-fast-io-1385
May 17, 2026
Merged

feat(fast_io): macOS kqueue event loop primitive (#1385)#4294
oferchen merged 1 commit into
masterfrom
feat/macos-kqueue-fast-io-1385

Conversation

@oferchen
Copy link
Copy Markdown
Owner

Summary

  • Scaffold the macOS kqueue event-loop primitive described in docs/design/macos-kqueue-fast-io.md (Adjust CI coverage gate and extend cross-platform builds #1385).
  • New kqueue::KqueueLoop wraps kqueue(2) / kevent(2) behind a safe API: read/write registration with edge-triggered EV_CLEAR, a Duration-bounded wait(), explicit remove(), and EOF/error inspection on returned events.
  • Stub module on every non-macOS target returns io::ErrorKind::Unsupported, so portable callers compile without #[cfg] branching and can probe via is_kqueue_available() at runtime.
  • Direct libc bindings (already a workspace unix dep) keep the unsafe surface to two FFI calls; the kqueue crate would add a dependency for the same syscalls in a higher-level shape that does not match the submit/wait usage pattern.
  • No behavioural change for current callers; consumer migrations (disk-commit thread, daemon accept loop) follow in later PRs.

Test plan

  • CI fmt + clippy
  • CI nextest (stable) - exercises new_loop_succeeds, read_event_fires_on_pipe_write, wait_returns_empty_on_timeout, remove_is_idempotent_on_missing_registration, eof_is_signalled_when_writer_closes on macOS, and the Unsupported stub assertions on Linux / Windows.
  • CI Windows + Linux musl - confirms the stub compiles on non-macOS targets.
  • CI macOS (stable) - exercises the real kqueue primitive end-to-end.

Scaffold the kqueue-driven event loop described in
docs/design/macos-kqueue-fast-io.md. Adds a safe wrapper over
kqueue(2) and kevent(2) that consumers (disk-commit thread, daemon
accept loop) will adopt in later PRs.

- crates/fast_io/src/kqueue/mod.rs - macOS implementation backed by
  direct libc bindings (libc is already a unix workspace dep, the
  unsafe surface is two FFI calls). Supports EVFILT_READ /
  EVFILT_WRITE registration with edge-triggered EV_CLEAR semantics,
  a Duration-bounded wait(), and explicit EV_DELETE removal.
- crates/fast_io/src/kqueue_stub.rs - cross-platform stub returning
  io::ErrorKind::Unsupported so callers compile on Linux / Windows
  without cfg branching.
- Unit tests cover loop creation, pipe-driven read wakeup,
  timeout-empty behaviour, EOF signalling, and idempotent removal.

No behavioural change for current callers; this lands the primitive
so subsequent PRs can migrate the disk-commit backend onto it.
@oferchen oferchen merged commit d276332 into master May 17, 2026
4 of 13 checks passed
@github-actions github-actions Bot added the enhancement New feature or request label May 17, 2026
oferchen added a commit that referenced this pull request May 18, 2026
Scaffold the kqueue-driven event loop described in
docs/design/macos-kqueue-fast-io.md. Adds a safe wrapper over
kqueue(2) and kevent(2) that consumers (disk-commit thread, daemon
accept loop) will adopt in later PRs.

- crates/fast_io/src/kqueue/mod.rs - macOS implementation backed by
  direct libc bindings (libc is already a unix workspace dep, the
  unsafe surface is two FFI calls). Supports EVFILT_READ /
  EVFILT_WRITE registration with edge-triggered EV_CLEAR semantics,
  a Duration-bounded wait(), and explicit EV_DELETE removal.
- crates/fast_io/src/kqueue_stub.rs - cross-platform stub returning
  io::ErrorKind::Unsupported so callers compile on Linux / Windows
  without cfg branching.
- Unit tests cover loop creation, pipe-driven read wakeup,
  timeout-empty behaviour, EOF signalling, and idempotent removal.

No behavioural change for current callers; this lands the primitive
so subsequent PRs can migrate the disk-commit backend onto it.
oferchen added a commit that referenced this pull request May 18, 2026
Scaffold the kqueue-driven event loop described in
docs/design/macos-kqueue-fast-io.md. Adds a safe wrapper over
kqueue(2) and kevent(2) that consumers (disk-commit thread, daemon
accept loop) will adopt in later PRs.

- crates/fast_io/src/kqueue/mod.rs - macOS implementation backed by
  direct libc bindings (libc is already a unix workspace dep, the
  unsafe surface is two FFI calls). Supports EVFILT_READ /
  EVFILT_WRITE registration with edge-triggered EV_CLEAR semantics,
  a Duration-bounded wait(), and explicit EV_DELETE removal.
- crates/fast_io/src/kqueue_stub.rs - cross-platform stub returning
  io::ErrorKind::Unsupported so callers compile on Linux / Windows
  without cfg branching.
- Unit tests cover loop creation, pipe-driven read wakeup,
  timeout-empty behaviour, EOF signalling, and idempotent removal.

No behavioural change for current callers; this lands the primitive
so subsequent PRs can migrate the disk-commit backend onto it.
@oferchen oferchen deleted the feat/macos-kqueue-fast-io-1385 branch May 19, 2026 19:29
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