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 21:04:05 +0000 (13:04 -0800)
commitb4941228cd03b125564fdb6d72755da2a3bbf63e
tree5e690e41c500e8896fb1d86e975be1e9a0502223
parentec14fc0d690f3ce6866e8732bb64ff6e3758a447
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
(cherry picked from commit 3fb5edd5046fcd04f359351f47e70ad37816977a)
bin/sh/eval.c
bin/sh/jobs.c
bin/sh/jobs.h
bin/sh/var.c
bin/sh/var.h