voidzero-dev / voidzero-dev/vite-task

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

Aperta
#627 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

enhancement
Lingua principale
Rust
Stelle
466
Fork
42
Merge medio
1g 15h
PR unite (30g)
19

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da Client::connect in crates/socket_ipc/src/unix.rs e leggi l'handshake macOS esistente e il codice di pubblicazione del PID del server. Analizza il comportamento di kqueue EVFILT_READ e EVFILT_PROC NOTE_EXIT descritto nell'issue, preservando il percorso POLLERR esistente di Linux. Il lavoro è completato quando l'attesa su macOS non include più un timeout di 100 ms né una verifica di riapertura e termina al verificarsi del byte di disponibilità oppure dell'uscita del server.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
macos, rust
Ambito
operating-systems
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.