From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: From: erik quanstrom Date: Fri, 20 Feb 2009 15:19:01 -0500 To: 9fans@9fans.net In-Reply-To: <20090220193401.KHHY16134.fed1rmmtao104.cox.net@fed1rmimpo03.cox.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] impact of dynamic libraries on the speed of fork() Topicbox-Message-UUID: a4ca63b4-ead4-11e9-9d60-3106f5b1d025 On Fri Feb 20 14:35:45 EST 2009, cmbrannon@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