Can I speed up cygwin's fork?

This has nothing to do with fork being slow.

I've seen cygwin run dog slow when the windows "home" directory was on a network drive. Every single command would search there for binaries slowing things down tremendously.

see if

while (true); do /bin/date --utc; done | uniq -c

is faster, if so, that is probably your problem

otherwise try running bash via strace/ltrace (if they even work on cygwin) and see what it is doing when it takes 1 second to execute date.


I'm afraid there is nothing much you can do about this.

Windows does not have a native fork() syscall so Cygwin has to emulate this. The implementation of this emulation is very inefficient though. (See Cygwin FAQ)

MSYS2, which is often used in applications where one wants a possibly fully featured Linux-like command line environment on windows, is based on Cygwin, which is why it's also affected by this.

It's actually so bad, that a fork() on Windows is at least one order of magnitude slower than on Linux

msys2bash-windows-box$ time { date; }
Sa, 24. Feb 2018 16:51:44

real    0m0,046s
user    0m0,000s
sys     0m0,000s

msys2bash-windows-box$ while (true); do /bin/date --utc; done | uniq -c
     13 Sa, 24. Feb 2018 15:57:18
     17 Sa, 24. Feb 2018 15:57:19
     16 Sa, 24. Feb 2018 15:57:20


bash-linux-box$ time { date; }
Sat Feb 24 15:51:54 UTC 2018

real    0m0.002s
user    0m0.000s
sys     0m0.000s

bash-linux-box$ while (true); do date --utc; done | uniq -c
    211 Sat Feb 24 15:56:35 UTC 2018
    286 Sat Feb 24 15:56:36 UTC 2018
    260 Sat Feb 24 15:56:37 UTC 2018

The above example shows the difference between an i5-2500k @ 4GHz, 32GiB RAM Windows 10 Pro box vs. a feeble one-core, 1GiB RAM VPS