Creating new processes is very slow on some of my machines, and not others.
The machines are all similar, and some of the slow machines are running the exact same workloads on the same hardware and kernel (2.6.32-26, Ubuntu 10.04) as some of the fast machines. Tasks that do not involve process creation are the same speeds on all machines.
For example, this program executes ~50 times slower on the affected machines:
int main()
{
int i;
for (i=0;i<10000;i++)
{
int p = fork();
if (!p) exit(0);
waitpid(p);
}
return 0;
}
What could be causing task creation to be much slower, and what other differences could I look for in the machines?
Edit1: Running bash scripts (as they spawn a lot of subprocesses) is also very slow on these machines, and strace on the slow scripts shows the slowdown in the clone()
kernel call.
Edit2: vmstat
doesn't show any significant differences on the fast vs slow machines. They all have more than enough RAM for their workloads and don't go to swap.
Edit3: I don't see anything suspicious in dmesg
Edit4: I'm not sure why this is on stackoverflow now, I'm not asking about the example program above (just using it to demonstrate the problem), but linux administration/tuning, but if people think it belongs here, cool.