async-process icon indicating copy to clipboard operation
async-process copied to clipboard

Use a more efficient strategy for waiting on processes

Open notgull opened this issue 1 year ago • 9 comments

Right now, we use SIGPROC to wait for process events on Unix and thread pooling to wait for process events on Windows. This is a very inefficient strategy that doesn't scale for many child processes, like using poll() for I/O notification.

Most operating systems have better ways of handling events like this.

  • Linux has pidfd, which can be registered directly into async-io.
  • BSD has EVFILT_PROC, which is now exposed in async-io.
  • Windows has waitable handles, which need to be exposed in async-io. They can also be made more efficient on the polling side, see smol-rs/async-io#25

notgull avatar Aug 20 '23 19:08 notgull