voidzero-dev / voidzero-dev/vite-task

socket_ipc: remove the 100 ms poll timeout from the macOS connect handshake

Offen
#627 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

enhancement
Vorherrschende Sprache
Rust
Sterne
466
Forks
42
Ø Merge
1 T. 15 Std.
Gemergte PRs (30 T.)
19

Beschreibung

Problem

While a client waits for the server's ready byte, it polls with a 100 ms timeout and reopens the connect FIFO on every tick to check that the server is alive.

The timeout is there because macOS does not report FIFO peer death. On Linux, POLLERR fires at once on the rendezvous write end. On macOS nothing fires, so an untimed wait would hang forever when the server dies mid-handshake.

Code: Client::connect in crates/socket_ipc/src/unix.rs (added in #569).

Measurements

macOS 27, run bare and inside both the Codex CLI and Claude Code sandboxes:

Watch Detects server death
poll POLLERR/POLLHUP on connect write end no, times out
kqueue EVFILT_WRITE EV_EOF on connect write end no, wakes writable without EV_EOF
kqueue EVFILT_READ EV_EOF on response read end no, times out
kqueue EVFILT_PROC NOTE_EXIT on the server pid yes, at once

No FIFO event reports a dead peer on macOS. Watching the process is the only mechanism that works.

Also measured, in both sandboxes:

  • EVFILT_READ delivers the ready byte reliably when the read end is opened before any writer exists, which is the handshake order.
  • Registering NOTE_EXIT on a pid that already exited returns ESRCH, so "server already gone" needs no extra race handling.
  • Watching an unrelated same-user pid is allowed, so the client can watch the runner.

Proposal

Register EVFILT_READ on the response FIFO and EVFILT_PROC NOTE_EXIT on the server pid in one kqueue, then block in a single kevent with no timeout. The wait ends when the ready byte arrives or the server exits. The 100 ms tick and the reopen probe both go away.

The server publishes its pid next to the connection name.

Cost

  • The connection name has to carry the server pid.
  • A pid reuse window appears. If the server exits and the same pid is reused during the handshake, the watch follows the wrong process. Darwin cycles through the pid space before reuse, so this is remote, while the current probe asks the kernel about the exact FIFO and has no such window.
  • macOS only. Linux keeps POLLERR and already needs no timeout.

Priority

Low. The happy path already wakes immediately, so the timeout only adds latency when the server dies during the handshake, which is rare.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit Client::connect in crates/socket_ipc/src/unix.rs und lesen Sie den vorhandenen macOS-Handshake sowie den Code zur Veröffentlichung der Server-PID. Untersuchen Sie das im Issue beschriebene Verhalten von kqueue EVFILT_READ und EVFILT_PROC NOTE_EXIT, wobei der bestehende POLLERR-Pfad von Linux erhalten bleiben muss. Als erledigt gilt die Aufgabe, wenn das Warten unter macOS kein 100-ms-Timeout oder keinen Reopen-Test mehr enthält und bei entweder dem Ready-Byte oder dem Beenden des Servers endet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
macos, rust
Bereich
operating-systems
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.