Article View: mod.std.unix
Article #67Re: limits; V4N7
From: Moderator, John Quarterman
Date: Mon, 09 Dec 1985 21:13
Date: Mon, 09 Dec 1985 21:13
95 lines
3310 bytes
3310 bytes
From: harvard!wjh12!panda!teddy!jpn (John P. Nelson)
Date: Mon, 9 Dec 85 11:35:09 est
>I decided to do a little testing to see how much the size of my
>environment affected response time.
>
I suspected that the iteration time was affected by the shell searching the
environment, rather than an increase in fork/exec time. I wrote a C program
to do the same thing as the shell script written by John P. Linderman. I
was wrong!
The following results were achieved on a diskless SUN-2 workstation (a
"perfmeter" running along side indicated 100% cpu usage, and 0% ethernet
activity - apparently everything remained in memory) I would have used a VAX,
but didn't want to annoy my fellow employees). Your numbers will vary:
% testit
Env size 56, loop time 135
Env size 113, loop time 139
Env size 227, loop time 158
Env size 455, loop time 167
Env size 911, loop time 207
Env size 1823, loop time 292
Env size 3647, loop time 470
Env size 7295, loop time 846
fork or exec failure: terminating
John P. Nelson (decvax!genrad!teddy!jpn seismo!harvard!talcott!panda!teddy!jpn)
--- cut here. testit.c follows: ---
#include <stdio.h>
char *env[2];
char *echoargv[] =
{
"echo",
"abc",
(char *) 0
};
#define DEFAULTENV "TEST=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
#define INNERLOOP 1000
main()
{
extern char *malloc(), *realloc();
register int i;
register char *ptr;
long starttime;
long endtime;
int waitst;
env[0] = malloc(sizeof(DEFAULTENV));
strcpy(env[0], DEFAULTENV);
env[1] = 0;
close(1); /* close up stdout */
if (open("/dev/null", 2) < 0)
{
fprintf(stderr, "Can't open /dev/null on 1\n");
}
while (1) /* or until failure */
{
time(&starttime);
for (i = 0; i < INNERLOOP; ++i)
{
/* do the fork/exec */
if (fork() == 0)
{
execve("/bin/echo", echoargv, env);
exit(-1); /* exec failure */
}
/* terminate on anything but successfull exit(0) */
if (wait(&waitst) < 0 || (waitst & 0xFFFF) != 0)
{
fprintf(stderr, "fork or exec failure: terminating\n");
exit(0);
}
}
time(&endtime);
fprintf(stderr, "Env size %d, loop time %ld\n",
strlen(env[0]), endtime - starttime);
/* now double the environment size */
env[0] = realloc(env[0], (strlen(env[0])+1) * 2);
ptr = env[0] + strlen(env[0]); /* point to trailing null */
strcpy(ptr+1, env[0]); /* tack on another copy */
*ptr = '\n'; /* and join the two strings */
}
/* NOTREACHED */
}
Volume-Number: Volume 4, Number 7
Technical Details
Message-ID:
<3757@ut-sally.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!decvax!decwrl!pyramid!ut-sally!std-unixReferences:
<3723@ut-sally.UUCP> <3718@ut-sally.UUCP> <3692@ut-sally.UUCP> <3575@ut-sally.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ut-sally.UUCP Path: arc1-ca.pugleaf.net!utzoo!decvax!decwrl!pyramid!ut-sally!std-unix From: std-unix@ut-sally.UUCP (Moderator, John Quarterman) Newsgroups: mod.std.unix Subject: Re: limits; V4N7 Message-ID: <3757@ut-sally.UUCP> Date: Mon, 9-Dec-85 16:13:23 EST Article-I.D.: ut-sally.3757 Posted: Mon Dec 9 16:13:23 1985 Date-Received: Mon, 9-Dec-85 22:31:37 EST References: <3723@ut-sally.UUCP> <3718@ut-sally.UUCP> <3692@ut-sally.UUCP> <3575@ut-sally.UUCP> Organization: IEEE/P1003 Portable Operating System Environment Committee Lines: 95 Approved: jsq@sally.UUCP