feat(fast_io): macOS kqueue event loop primitive (#1385)#4294
Merged
Conversation
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
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.
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
docs/design/macos-kqueue-fast-io.md(Adjust CI coverage gate and extend cross-platform builds #1385).kqueue::KqueueLoopwrapskqueue(2)/kevent(2)behind a safe API: read/write registration with edge-triggeredEV_CLEAR, aDuration-boundedwait(), explicitremove(), and EOF/error inspection on returned events.io::ErrorKind::Unsupported, so portable callers compile without#[cfg]branching and can probe viais_kqueue_available()at runtime.libcbindings (already a workspace unix dep) keep the unsafe surface to two FFI calls; thekqueuecrate would add a dependency for the same syscalls in a higher-level shape that does not match the submit/wait usage pattern.Test plan
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_closeson macOS, and theUnsupportedstub assertions on Linux / Windows.