[mod.std.unix] limits; V4N6

std-unix@ut-sally.UUCP (Moderator, John Quarterman) (12/06/85)

Date: Thu, 5 Dec 85 16:45:19 cst
From: allegra!jpl (John P. Linderman)

I decided to do a little testing to see how much the size of my
environment affected response time.  I wrote the following korn shell
script, and ran in on an unloaded (but not singleuser) VAX 8600.  Each
main loop runs /bin/echo 1000 times, with exported variable ``a'' doubling
in size each time through the outer loop.  I unset as much as possible,
to minimize the environment, as the export at the start shows.  Adding
a seventh iteration to the outside loop made the environment too big.
All the commands in the inner loop except /bin/echo are shell builtins,
so there should be only one fork and exec per iteration.

#!/bin/ksh
a="`cat /etc/fstab`"
unset MAILCHECK RANDOM
export
export a
for i in 1 2 3 4 5 6
do
    export | /usr/ucb/wc
    /bin/date
    j=0
    while let "j = j + 1"  "j <= 1000"
    do
	/bin/echo abc > /dev/null
    done
    /bin/date
    a="$a
$a"
done

The results follow.

HOME=/
PWD=/
      10      10     181
Thu Dec  5 10:51:01 EST 1985
Thu Dec  5 10:52:12 EST 1985    ( 71 seconds)
      18      18     347
Thu Dec  5 10:52:13 EST 1985
Thu Dec  5 10:53:40 EST 1985	( 87 seconds)
      34      34     679
Thu Dec  5 10:53:40 EST 1985
Thu Dec  5 10:55:11 EST 1985	( 91 seconds)
      66      66    1343
Thu Dec  5 10:55:11 EST 1985
Thu Dec  5 10:56:59 EST 1985	(108 seconds)
     130     130    2671
Thu Dec  5 10:56:59 EST 1985
Thu Dec  5 10:59:02 EST 1985	(123 seconds)
     258     258    5327
Thu Dec  5 10:59:03 EST 1985
Thu Dec  5 11:02:35 EST 1985	(152 seconds)

There are many possible interpretations of the data, of which I am
certain we'll hear several.  I hadn't expected the size of the
environment to matter as much as it did, but the bottom line for me, on
my nice fast machine, is that the biggest environment I'm allowed to
carry around adds at most a tenth of a second to a fork+exec.  The
actual environment I carry around (about 900 bytes) adds somewhere
around 3 hundredths of a second to that cost.  I simply don't execute
enough processes in a day for that to make a difference.  On a slower
machine, my interpretation might be different.  I'd be curious to
see the results of a similar test on other machines.

John P. Linderman   Environmental Studies Department  allegra!jpl

Volume-Number: Volume 4, Number 6