Date: Thu, 18 May 2017 22:10:04 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r318502 - head/bin/sh Message-ID: <201705182210.v4IMA48d054969@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705182210.v4IMA48d054969>