On Fri Feb 20 14:35:45 EST 2009, cmbran...@cox.net wrote: > I wrote a really simple program, forktest.c. > Next, I performed some experiments using this program. Fork is faster > for statically linked executables. It becomes slower as more libraries > are added to a dynamically linked executable. > These tests were done on an x86 machine running Linux. > Here is a transcript of my experiments, followed by the source for forktest. > > -- Chris
very nice. i wonder if you may be measuring the performance of memory management more than the performance of dynamic linking. the reason i suspect this is because on my p3 machine i see gcc static 13440 f/s gcc dyn 12953 f/s gcc static 6963 fork + exec/s or the tipoff is the size of the executable: ; ls -l a.out -rwxr-xr-x 1 quanstro users 609298 Feb 20 14:36 a.out for snarky comparison, here are the programs on my system that are that large or larger: --rwxrwxr-x M 48625 sys sys 13275174 Jan 16 2006 /bin/gs --rwxrwxr-x M 48625 sys sys 758520 Dec 9 2005 /bin/spin the hard bit would be keeping the memory footprint the same while increasing the number of shared libraries. even in bad cases, this is like 0.2ms/fork + exec. i wonder if the reason that there can be such big differences is that linux fork+exec may have been massaged for such syntetic benchmarks. thus small amounts of extra work might look big. - erik