aboutsummaryrefslogtreecommitdiffstats
path: root/ninja.cc
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2016-09-30 20:17:14 -0700
committerDan Willemsen <dwillemsen@google.com>2016-10-01 12:46:04 -0700
commit064be227bfc5948a74e034fd613d556a49e8b49b (patch)
treea2fe0615ee60651cc5014a1d689db797965b88f1 /ninja.cc
parent9862c2a1dc844d431cf3f9cca41603362cc077c9 (diff)
downloadandroid_build_kati-064be227bfc5948a74e034fd613d556a49e8b49b.tar.gz
android_build_kati-064be227bfc5948a74e034fd613d556a49e8b49b.tar.bz2
android_build_kati-064be227bfc5948a74e034fd613d556a49e8b49b.zip
Optimize RunCommand by removing /bin/sh wrapper when possible
For every $(shell echo "test: $PATH") command, when SHELL is /bin/bash, we essentially run: (each arg wrapped in []) [/bin/sh] [-c] [/bin/bash -c "echo \"test: \$PATH\""] This is redundant, since we can just use SHELL, and then we don't need to do an extra level of shell escaping either. This change makes us run this instead: [/bin/bash] [-c] [echo "test: $PATH"] If SHELL is more complicated than an absolute path to a binary, then we'll fall back to /bin/sh. Using the benchmark introduced in the last change, this reduces a minimal RunCommand execution with a simple SHELL from 3.7ms to 1.3ms. For a more complex benchmark (though less normalized), for an AOSP Android build, this change shrinks the average time spent in $(shell) functions from 4.5ms to 3ms. Change-Id: I622116e33565e58bb123ee9e9bdd302616a6609c
Diffstat (limited to 'ninja.cc')
-rw-r--r--ninja.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/ninja.cc b/ninja.cc
index 90fe404..e2bc9cd 100644
--- a/ninja.cc
+++ b/ninja.cc
@@ -737,6 +737,7 @@ class NinjaGenerator {
DumpInt(fp, crs.size());
for (CommandResult* cr : crs) {
DumpString(fp, cr->shell);
+ DumpString(fp, cr->shellflag);
DumpString(fp, cr->cmd);
DumpString(fp, cr->result);
if (!cr->find.get()) {