diff options
author | jilles <jilles@FreeBSD.org> | 2012-02-04 23:12:14 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2012-02-04 23:12:14 +0000 |
commit | c9a60ad55a7cdcf983430853a4bdb15d31340f0b (patch) | |
tree | cdf2aa0b0a8655054be3d8275658129bb9b75c99 /bin/sh/var.c | |
parent | a3ada8a47cbcc2eecf9773251384c95d920c9cab (diff) | |
download | FreeBSD-src-c9a60ad55a7cdcf983430853a4bdb15d31340f0b.zip FreeBSD-src-c9a60ad55a7cdcf983430853a4bdb15d31340f0b.tar.gz |
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.
Diffstat (limited to 'bin/sh/var.c')
-rw-r--r-- | bin/sh/var.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/bin/sh/var.c b/bin/sh/var.c index b3bc6f7f..bc00e06 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -94,6 +94,7 @@ struct var vps2; struct var vps4; struct var vvers; static struct var voptind; +struct var vdisvfork; int forcelocal; @@ -125,6 +126,8 @@ static const struct varinit varinit[] = { #endif { &voptind, 0, "OPTIND=1", getoptsreset }, + { &vdisvfork, VUNSET, "SH_DISABLE_VFORK=", + NULL }, { NULL, 0, NULL, NULL } }; |