static/dynamic links: performance question

Robert Viduya robert at shangri-la.gatech.edu
Tue Jul 31 01:57:32 AEST 1990


A friend of mine has noticed a slighty disturbing behaviour with SunOS 4.1
on SS1's and 1+'s.  He was benchmarking the machine using the Dhrystone
program and, well, see for yourselves:

    $ cc -O4 -DREG=register dry.c -o dryr; dryr
    Dhrystone(1.1) time for 250000 passes = 13
    This machine benchmarks at 18844 dhrystones/second

    $ cc -Bstatic -O4 -DREG=register dry.c -o dryr; dryr
    Dhrystone(1.1) time for 250000 passes = 11
    This machine benchmarks at 22058 dhrystones/second

The only difference between the two runs is that the second one is linked
statically.  The result is a 17% speedup.  He suspects the static and
dynamic libraries are different.  At first, I thought it might be the
global optimizer being able to do a better job when linking statically,
but when I compiled with -O1, I still got a 15% speedup on static links.
(Further investigation shows that Sun's global optimizer only works on a
single source file basis; it doesn't optimize across multiple source
files.)  Can anyone explain what's going on here?  Are the libraries
different or do dynamic links really cost that much?

Robert Viduya					  robert at shangri-la.gatech.edu



More information about the Comp.sys.sun mailing list