Dmake slowness ... - why !?

Lots of forks:
(dmake/unix/runargv.c ?)

    + The unix runargv is called on Win32 too
	+ we fork 'tcsh' for 'echo' since for 4NT echo is an
	  external process, not needed for Unix though.

    PUBLIC int
    runargv(target, ignore, group, last, shell, cmd)

    PUBLIC int
    Do_cmnd(cmd, group, do_it, target, ignore, shell, last)

./mac/bogus.c:66:runargv (CELLPTR target, int ignore, int,
./mac/bogus.c:77:} /* int runargv () */
./qssl/runargv.c:1:/* RCS  $Id: dmake.txt,v 1.2 2006/02/07 19:05:38 martink Exp $
./qssl/runargv.c:62:runargv(target, ignore, group, last, shell, cmd)
./qssl/runargv.c:223:      runargv( _procs[i].pr_target, rp->prp_ignore, rp->prp_group,
./unix/runargv.c:1:/* $RCSfile: dmake.txt,v $
./unix/runargv.c:107:runargv(target, ignore, group, last, shell, cmd)
./unix/runargv.c:290:      runargv( _procs[i].pr_target, rp->prp_ignore, rp->prp_group,
./msdos/runargv.c:1:/* RCS  $Id: dmake.txt,v 1.2 2006/02/07 19:05:38 martink Exp $
./msdos/runargv.c:36:runargv(target, ignore, group, last, shell, cmd)
./win95/microsft/vpp40/runargv.c:3:/* RCS  $Id: dmake.txt,v 1.2 2006/02/07 19:05:38 martink Exp $
./win95/microsft/vpp40/runargv.c:68:runargv(target, ignore, group, last, shell, cmd)
./win95/microsft/vpp40/runargv.c:217:      runargv( _procs[i].pr_target, rp->prp_ignore, rp->prp_group,
./winnt/microsft/vpp40/runargv.c:3:/* RCS  $Id: dmake.txt,v 1.2 2006/02/07 19:05:38 martink Exp $
./winnt/microsft/vpp40/runargv.c:68:runargv(target, ignore, group, last, shell, cmd)
./winnt/microsft/vpp40/runargv.c:217:      runargv( _procs[i].pr_target, rp->prp_ignore, rp->prp_group,
./sysintf.c:31:--               runargv()
./sysintf.c:200:   if( (i = runargv(target, ignore, group, last, shell, cmd)) == -1 )
./sysintf.c:203:   /* NOTE:  runargv must return either 0 or 1, 0 ==> command executed, and


32049 execve("/usr/bin/perl", ["perl", "../solenv/bin/build.pl"], [/* 300 vars */]) = 0
32050 execve("/bin/pwd", ["/bin/pwd"], [/* 300 vars */] <unfinished ...>
32050 <... execve resumed> )            = 0
32051 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake", "-V"], [/* 301 vars */] <unfinished ...>
32051 <... execve resumed> )            = 0
32052 execve("/bin/pwd", ["/bin/pwd"], [/* 301 vars */]) = 0
32053 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake"], [/* 301 vars */]) = 0
32054 execve("/bin/date", ["date", "+%d%m%Y"], [/* 307 vars */]) = 0
32055 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo -------------"], [/* 308 vars */]) = 0
32056 execve("/bin/pwd", ["/bin/pwd"], [/* 301 vars */] <unfinished ...>
32056 <... execve resumed> )            = 0
32057 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake"], [/* 301 vars */]) = 0
32058 execve("/bin/date", ["date", "+%d%m%Y"], [/* 307 vars */]) = 0
32059 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo \"Nothing to build for GUIBA"...], [/* 308 vars */]) = 0
32060 execve("/bin/pwd", ["/bin/pwd"], [/* 301 vars */] <unfinished ...>
32060 <... execve resumed> )            = 0
32061 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake"], [/* 301 vars */]) = 0
32062 execve("/bin/date", ["date", "+%d%m%Y"], [/* 307 vars */]) = 0
32063 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo \"Nothing to build for GUIBA"...], [/* 308 vars */]) = 0
32064 execve("/bin/pwd", ["/bin/pwd"], [/* 301 vars */]) = 0
32065 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake"], [/* 301 vars */]) = 0
32066 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo ..."], [/* 302 vars */]) = 0
32067 execve("/bin/pwd", ["/bin/pwd"], [/* 301 vars */] <unfinished ...>
32067 <... execve resumed> )            = 0
32068 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake"], [/* 301 vars */]) = 0
32069 execve("/bin/date", ["date", "+%d%m%Y"], [/* 307 vars */]) = 0
32070 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo \"Nothing to build for GUIBA"...], [/* 308 vars */]) = 0
32071 execve("/bin/pwd", ["/bin/pwd"], [/* 301 vars */]) = 0
32072 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake"], [/* 301 vars */]) = 0
32073 execve("/bin/date", ["date", "+%d%m%Y"], [/* 307 vars */]) = 0
32074 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo --- EXCEPTIONSFILES ---"], [/* 308 vars */]) = 0
32075 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "dmake  -f makefile.mk ENABLE_EXC"...], [/* 308 vars */]) = 0
32076 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake", "-f", "makefile.mk", "ENABLE_EXCEPTIONS=true", "../../unxlngi6.pro/slo/svapp.obj"..., "../../unxlngi6.pro/slo/svdata.ob"..., "../../unxlngi6.pro/slo/dndhelp.o"..., "../../unxlngi6.pro/slo/unohelp.o"..., "../../unxlngi6.pro/slo/unohelp2."..., "../../unxlngi6.pro/slo/i18nhelp."..., "../../unxlngi6.pro/slo/svmain.ob"..., "../../unxlngi6.pro/slo/session.o"..., "EXCEPTIONS_FLAG=TRUE"], [/* 310 vars */]) = 0
32077 execve("/bin/date", ["date", "+%d%m%Y"], [/* 310 vars */]) = 0
32079 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo --- EXCEPTIONSFILES OVER --"...], [/* 308 vars */]) = 0
32080 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo -------------"], [/* 308 vars */]) = 0
32081 execve("/bin/pwd", ["/bin/pwd"], [/* 301 vars */] <unfinished ...>
32081 <... execve resumed> )            = 0
32082 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake"], [/* 301 vars */]) = 0
32083 execve("/bin/date", ["date", "+%d%m%Y"], [/* 307 vars */]) = 0
32084 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo --- EXCEPTIONSFILES ---"], [/* 308 vars */]) = 0
32085 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "dmake  -f makefile.mk ENABLE_EXC"...], [/* 308 vars */]) = 0
32086 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake", "-f", "makefile.mk", "ENABLE_EXCEPTIONS=true", "../../unxlngi6.pro/slo/edit.obj", "../../unxlngi6.pro/slo/field2.ob"..., "../../unxlngi6.pro/slo/ilstbox.o"..., "../../unxlngi6.pro/slo/tabctrl.o"..., "EXCEPTIONS_FLAG=TRUE"], [/* 310 vars */]) = 0
32087 execve("/bin/date", ["date", "+%d%m%Y"], [/* 310 vars */]) = 0
32088 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo --- EXCEPTIONSFILES OVER --"...], [/* 308 vars */]) = 0
32089 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo -------------"], [/* 308 vars */]) = 0
32090 execve("/bin/pwd", ["/bin/pwd"], [/* 301 vars */]) = 0
32091 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake"], [/* 301 vars */]) = 0
32092 execve("/bin/date", ["date", "+%d%m%Y"], [/* 307 vars */]) = 0
32093 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo --- EXCEPTIONSFILES ---"], [/* 308 vars */]) = 0
32094 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "dmake  -f makefile.mk ENABLE_EXC"...], [/* 308 vars */]) = 0
32095 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake", "-f", "makefile.mk", "ENABLE_EXCEPTIONS=true", "../../unxlngi6.pro/slo/outdev.ob"..., "../../unxlngi6.pro/slo/gfxlink.o"..., "../../unxlngi6.pro/slo/print.obj"..., "../../unxlngi6.pro/slo/impgraph."..., "../../unxlngi6.pro/slo/bmpconv.o"..., "../../unxlngi6.pro/slo/pdfextout"..., "../../unxlngi6.pro/slo/impimaget"..., "../../unxlngi6.pro/slo/virdev.ob"..., "EXCEPTIONS_FLAG=TRUE"], [/* 310 vars */]) = 0
32096 execve("/bin/date", ["date", "+%d%m%Y"], [/* 310 vars */]) = 0
32097 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo --- EXCEPTIONSFILES OVER --"...], [/* 308 vars */]) = 0
32098 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo -------------"], [/* 308 vars */]) = 0
32099 execve("/bin/pwd", ["/bin/pwd"], [/* 301 vars */]) = 0
32100 execve("/opt/OpenOffice/src680-m152/solenv/unxlngi6/bin/dmake", ["dmake"], [/* 301 vars */]) = 0
32101 execve("/bin/date", ["date", "+%d%m%Y"], [/* 307 vars */]) = 0
32102 execve("/usr/bin/tcsh", ["/usr/bin/tcsh", "-fc", "echo -------------"], [/* 308 vars */]) = 0
32103 execve("/bin/pwd", ["/bin/pwd"], [/* 301 vars */] <unfinished ...>
32103 <... execve resumed> )            = 0

Proto patch for builtin 'dmake':

Index: unix/runargv.c
===================================================================
RCS file: /cvs/tools/dmake/unix/runargv.c,v
retrieving revision 1.8
diff -u -p -u -r1.8 runargv.c
--- unix/runargv.c	8 Sep 2004 16:09:39 -0000	1.8
+++ unix/runargv.c	7 Feb 2006 17:49:08 -0000
@@ -103,6 +103,44 @@ private_strerror (errnum)
 #define strerror private_strerror
 #endif /* HAVE_STRERROR */
 
+/* A set of commands that handle some things we do a lot */
+static int
+builtin_do_date (argv, ret)
+char ** argv;
+int *ret;
+{
+  if (argv[1] && !strcmp (argv[1], "+%d%m%Y"))
+  {
+    fprintf (stdout, "dateseldomused\n");
+	*ret = 1;
+	return 1;
+  }
+  return 0;
+}
+
+static int
+exec_builtin_command (argv, ret)
+char ** argv;
+int *ret;
+{
+  const char *command;
+
+  if (!argv || !argv[0])
+    return 0;
+
+  command = argv[0];
+
+  if (!strcmp (command, "date"))
+    return builtin_do_date (argv, ret);
+
+
+  fprintf (stderr, "Command: '%s' args:", argv[0]);
+  while (*argv)
+		  fprintf (stderr, "'%s' ", *argv++);
+  fprintf (stderr, "\n");
+  return 0;
+}
+
 PUBLIC int
 runargv(target, ignore, group, last, shell, cmd)
 CELLPTR target;
@@ -113,6 +151,7 @@ int     shell;
 char	*cmd;
 {
    int          pid;
+   int          ret;
    char         **argv;
 
    if( _running(target) /*&& Max_proc != 1*/ ) {
@@ -138,6 +177,9 @@ char	*cmd;
 
    argv = Pack_argv( group, shell, cmd );
 
+   if (exec_builtin_command (argv, &ret))
+	   return ret;
+
 #if HAVE_SPAWN_H
    if (posix_spawn (&pid, argv[0], NULL, NULL, argv, (char *)NULL))
    {   /* posix_spawn failed */


It might be possible to eliminate most date calls completely (yeah, I
know builtin_do_date is just an example). Superficial grepping in
solenv/inc/*mk makes it look like the date call is in a file that
everybody .INCLUDEs, to set a variable that affects only scp2 (?).
