Simple program to test fork() performance. #include <sys/signal.h> #include <sys/time.h>
int main(int argc, char *argv[]) { int pid; int i = 0, max = 100000; struct timeval tv0, tv1; struct timezone tz; long diff; if (argc >= 2) max = atoi(argv[1]); signal(SIGCHLD, SIG_IGN); gettimeofday(&tv0, &tz); while (i++ < max) { pid = fork(); if (pid == 0) { sleep(1); exit (0); } } gettimeofday(&tv1, &tz); diff = (tv1.tv_sec - tv0.tv_sec)*1000000 + (tv1.tv_usec - tv0.tv_usec); printf("Average per process fork+exit time is %ld usecs [diff=%lu, max=%d].\n", diff/max, diff, max); return 0; } Creating 10k forks 100 times. Results on 2-way SMP(1+1HT) Xeon for one fork()+exit(): 2.6.11-rc4-mm1 494 usec 2.6.11-rc4-mm1-fork-connector-no_userspace 509 usec 2.6.11-rc4-mm1-fork-connector-userspace 520 usec 5% fork() degradation(connector with userspace vs. vanilla) with fork() connector. On my test system global fork lock does not cost anything (tested both with and without userspace listener), but it is only 2-way(pseudo). -- Evgeniy Polyakov Crash is better than data corruption -- Arthur Grabowski
signature.asc
Description: This is a digitally signed message part