Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I came across a post discussing the speed of forking in Cygwin, giving an expected 'fork rate' in Windows XP of around 30-50 per-second (link)

I've got a Core 2 duo (1.79GHz) which I would expect to get comparable results, but it's only managing around 8 forks per second (and sometimes a lot fewer):

$ while (true); do date --utc; done | uniq -c
      5 Wed Apr 21 12:38:10 UTC 2010
      6 Wed Apr 21 12:38:11 UTC 2010
      1 Wed Apr 21 12:38:12 UTC 2010
      1 Wed Apr 21 12:38:13 UTC 2010
      8 Wed Apr 21 12:38:14 UTC 2010
      8 Wed Apr 21 12:38:15 UTC 2010
      6 Wed Apr 21 12:38:16 UTC 2010
      1 Wed Apr 21 12:38:18 UTC 2010
      9 Wed Apr 21 12:38:19 UTC 2010

Can you suggest anything I might be able to do to speed things up? This machine acts a lot slower in Cygwin than others I've used before which actually were a lot slower.


Let my justify my question: I don't believe that having a faster fork will magically make my life better, but I believe that this benchmark is a good proxy for the performance issues I'm seeing in bash due to normal use of external executables to calculate values. I find I get a noticeable speed up on Cygwin by going through my shell start up scripts and bash-completion and trying to replace external commands with internal ones; on Linux this isn't an issue. Often, though, this isn't possible, and my PC is currently taking ~14s to start a shell with a warm cache and no load.

share|improve this question
Cygwin will be always slow, slower. Even VirtualBox/VMWare would give faster performance, or if you need a dev environment, go with msys. But this... don't know.. never really found cygwin useable. – Shiki Jun 7 '10 at 18:37
+1 for the nice, simple fork benchmark! Just ran this on a 5$/month Linux VPS to compare with my i7 Windows laptop, and the VPS scored 30x higher. – Mark K Cowan Jul 30 '14 at 18:57

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.

share|improve this answer
Unfortunately, hard-coding the paths makes no appreciable difference. strace does work in Cygwin, but nothing jumps out at me when I look at the trace. – Andrew Aylett Apr 22 '10 at 13:46

You're not seeing forks; you're seeing fork, exec, system call to read time of day clock, format and convert the output. Not to mention whatever else is time sharing in parallel.

On what basis do you say the other machines "actually were slower"? There are a lot of things that contribute to a computer's actual speed and to the user's perception of the computer speed. What sort of things are you doing where forks/sec is a good measure of performance? What's the memory speed, architecture and amount? Disk I/O speed and buffering?

Which do you think will do more forks/sec: a Core i7 running Vista with 512MB of RAM or a Celeron running a minimal Linux with 2 GB?

share|improve this answer
@mpez0: Please see my updated justification. To answer your questions specifically, my basis for saying that they were slower is that they were of an older architecture with a slower clock speed, less (and slower) RAM and an older, slower disk, but still XP. Linux will almost always be faster at forking, because it uses a forking model in the kernel where Windows doesn't. I have a P3 which scores ~60 on that benchmark :). – Andrew Aylett Apr 21 '10 at 17:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .