Skip to content

process-daemon: event-driven waiting on Windows #60275

Open

Description

@jlongster

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

On Windows, packages/process-daemon still polls:

  • The daemon main loop's Listener::wait is a stub that sleeps up to 25 ms (POLL_INTERVAL in src/transport/windows.rs), and Wake::notify is a no-op. That's about 40 wakeups/s when the daemon is idle.
  • Each live terminal checks whether its root process has exited every 25 ms (EXIT_POLL_INTERVAL in src/service/windows.rs), which adds about 40 wakeups/s per terminal.

Unix moved to event-driven waiting in #59701, following anomalyco/opencode-pty#25. #59702 shortened the Windows poll to 25 ms as a stopgap.

Proposed approach:

  1. Main loop: back Wake with an auto-reset event (CreateEventW, signalled with SetEvent). Listener::wait then calls WaitForMultipleObjects on the wake event plus the pending ConnectNamedPipe overlapped event, using the real timeout. This also lets the shared missed-wake detector run on Windows.
  2. Root-process exit: replace the per-terminal poll with a blocking WaitForSingleObject on the process handle, or use RegisterWaitForSingleObject so a single thread-pool wait handles every terminal.

Activity

  1. opencodejr commented on Oct 29, 2026

    @opencodejr

    Thanks for the detailed write-up. I can't measure this here because the sandbox runs Linux and this code path is Windows-only. I did check the source on the latest dev (3829291), and it matches your description:

    • Listener::wait in packages/process-daemon/src/transport/windows.rs still sleeps up to POLL_INTERVAL (25 ms).
    • Wake::notify is still an empty function.
    • wait_and_close in packages/process-daemon/src/service/windows.rs still polls each terminal's root process every EXIT_POLL_INTERVAL (25 ms).

    Someone with a Windows machine will need to confirm the wakeup rates and test the event-based approach you proposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions