aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2016-03-07 19:12:48 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-03-08 03:44:51 +0000
commitadc706fd0295cef7cd1461daca141f012910eca3 (patch)
tree67570ff3c7807a062342977c3d450a6da01c0b35
parent4367a54b427649318b2b3c2828b6f61104023ea9 (diff)
Add a new startup option, --experimental_oom_more_eagerly. Features to have Bazel exit more eagerly due to an OOM will be guarded by this flag.
-- MOS_MIGRATED_REVID=116567102
-rw-r--r--src/main/cpp/blaze.cc3
-rw-r--r--src/main/cpp/blaze_startup_options.cc1
-rw-r--r--src/main/cpp/blaze_startup_options.h2
-rw-r--r--src/main/cpp/blaze_startup_options_common.cc8
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java11
5 files changed, 25 insertions, 0 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
index 336dbc2d8e..9591a3cd96 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -271,6 +271,9 @@ static vector<string> GetArgumentArray() {
} else {
result.push_back("--nodeep_execroot");
}
+ if (globals->options.oom_more_eagerly) {
+ result.push_back("--experimental_oom_more_eagerly");
+ }
if (globals->options.watchfs) {
result.push_back("--watchfs");
}
diff --git a/src/main/cpp/blaze_startup_options.cc b/src/main/cpp/blaze_startup_options.cc
index acb3b466f6..7a27abe1ec 100644
--- a/src/main/cpp/blaze_startup_options.cc
+++ b/src/main/cpp/blaze_startup_options.cc
@@ -51,6 +51,7 @@ BlazeStartupOptions::BlazeStartupOptions(const BlazeStartupOptions &rhs)
batch_cpu_scheduling(rhs.batch_cpu_scheduling),
io_nice_level(rhs.io_nice_level),
max_idle_secs(rhs.max_idle_secs),
+ oom_more_eagerly(rhs.oom_more_eagerly),
watchfs(rhs.watchfs),
allow_configurable_attributes(rhs.allow_configurable_attributes),
option_sources(rhs.option_sources),
diff --git a/src/main/cpp/blaze_startup_options.h b/src/main/cpp/blaze_startup_options.h
index 59b893ecf2..d82bfad00c 100644
--- a/src/main/cpp/blaze_startup_options.h
+++ b/src/main/cpp/blaze_startup_options.h
@@ -146,6 +146,8 @@ class BlazeStartupOptions {
int max_idle_secs;
+ bool oom_more_eagerly;
+
// If true, Blaze will listen to OS-level file change notifications.
bool watchfs;
diff --git a/src/main/cpp/blaze_startup_options_common.cc b/src/main/cpp/blaze_startup_options_common.cc
index a6404182eb..4b0633593b 100644
--- a/src/main/cpp/blaze_startup_options_common.cc
+++ b/src/main/cpp/blaze_startup_options_common.cc
@@ -50,6 +50,7 @@ void BlazeStartupOptions::Init() {
// 3 hours (but only 5 seconds if used within a test)
max_idle_secs = testing ? 5 : (3 * 3600);
webstatus_port = 0;
+ oom_more_eagerly = false;
watchfs = false;
invocation_policy = NULL;
}
@@ -80,6 +81,7 @@ void BlazeStartupOptions::Copy(
lhs->io_nice_level = rhs.io_nice_level;
lhs->max_idle_secs = rhs.max_idle_secs;
lhs->webstatus_port = rhs.webstatus_port;
+ lhs->oom_more_eagerly = rhs.oom_more_eagerly;
lhs->watchfs = rhs.watchfs;
lhs->allow_configurable_attributes = rhs.allow_configurable_attributes;
lhs->fatal_event_bus_exceptions = rhs.fatal_event_bus_exceptions;
@@ -204,6 +206,12 @@ blaze_exit_code::ExitCode BlazeStartupOptions::ProcessArg(
} else if (GetNullaryOption(arg, "-x")) {
fprintf(stderr, "WARNING: The -x startup option is now ignored "
"and will be removed in a future release\n");
+ } else if (GetNullaryOption(arg, "--experimental_oom_more_eagerly")) {
+ oom_more_eagerly = true;
+ option_sources["experimental_oom_more_eagerly"] = rcfile;
+ } else if (GetNullaryOption(arg, "--noexperimental_oom_more_eagerly")) {
+ oom_more_eagerly = false;
+ option_sources["experimental_oom_more_eagerly"] = rcfile;
} else if (GetNullaryOption(arg, "--watchfs")) {
watchfs = true;
option_sources["watchfs"] = rcfile;
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java
index 9f6ce88ed1..bd07e166e1 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java
@@ -166,6 +166,17 @@ public class BlazeServerStartupOptions extends OptionsBase {
+ "$OUTPUT_BASE")
public boolean deepExecRoot;
+ @Option(
+ name = "experimental_oom_more_eagerly",
+ defaultValue = "false", // NOTE: purely decorative! See class docstring.
+ category = "server startup",
+ help =
+ "If set, attempt to detect Java heap OOM conditions and exit before thrashing. Only "
+ + "honored when --batch is also passed. In some cases, builds that previously succeeded"
+ + " may OOM if they were close to OOMing before."
+ )
+ public boolean oomMoreEagerly;
+
@Option(name = "block_for_lock",
defaultValue = "true", // NOTE: purely decorative! See class docstring.
category = "server startup",