sh: Use vfork in a few common cases.
authorPeter Avalos <pavalos@dragonflybsd.org>
Sun, 5 Feb 2012 20:21:25 +0000 (12:21 -0800)
committerPeter Avalos <pavalos@dragonflybsd.org>
Sun, 5 Feb 2012 20:48:26 +0000 (12:48 -0800)
commit3fb5edd5046fcd04f359351f47e70ad37816977a
tree4d0e4fd90479bbbda3c5af9997a5b5e2b386defd
parent723ecb596978d3ed4d37a449ce636a35c743ec80
sh: Use vfork in a few common cases.

This uses vfork() for simple commands and command substitutions containing a
single simple command, invoking an external program under certain conditions
(no redirections or variable assignments, non-interactive shell, no job
control). These restrictions limit the amount of code executed in a vforked
child.

There is a large speedup (for example 35%) in microbenchmarks. The
difference in buildkernel is smaller (for example 0.5%) but still
statistically significant. See
http://lists.freebsd.org/pipermail/freebsd-hackers/2012-January/037581.html
for some numbers.

The use of vfork() can be disabled by setting a variable named
SH_DISABLE_VFORK.

Obtained-from:  FreeBSD 230998
bin/sh/eval.c
bin/sh/jobs.c
bin/sh/jobs.h
bin/sh/var.c
bin/sh/var.h