Author: jilles
Date: Thu May 18 22:10:04 2017
New Revision: 318502
URL: https://svnweb.freebsd.org/changeset/base/318502

Log:
  sh: Keep output buffer across builtins.
  
  Allocating and deallocating repeatedly the 1024-byte buffer for stdout from
  builtins costs CPU time for little or no benefit.
  
  A simple loop containing builtins that write to a file descriptor, such as
    i=0; while [ "$i" -lt 1000000 ]; do printf .; i=$((i+1)); done >/dev/null
  is over 10% faster in a simple benchmark on an amd64 virtual machine.

Modified:
  head/bin/sh/output.c

Modified: head/bin/sh/output.c
==============================================================================
--- head/bin/sh/output.c        Thu May 18 21:44:14 2017        (r318501)
+++ head/bin/sh/output.c        Thu May 18 22:10:04 2017        (r318502)
@@ -254,14 +254,7 @@ flushout(struct output *dest)
 void
 freestdout(void)
 {
-       INTOFF;
-       if (output.buf) {
-               ckfree(output.buf);
-               output.nextc = NULL;
-               output.buf = NULL;
-               output.bufend = NULL;
-       }
-       INTON;
+       output.nextc = output.buf;
 }
 
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to