diff options
author | Benjamin Peterson <bp@benjamin.pe> | 2018-08-08 05:29:34 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-08-08 05:30:57 -0700 |
commit | f05c0a48dc298ad3e90f3acb399cc53c2944a801 (patch) | |
tree | 795daf89b1a2f0038dbbdb42fdf7d53c492bf259 /src/main/cpp | |
parent | af33d82884d69df89f83dc29f765d05c67605780 (diff) |
Add a option to disable idle gc.
If a Bazel server is idle for 10 seconds, it unconditionally triggers a full-scale Java GC via System.gc(). This behavior doesn't have clear benefits and causes Bazel to steal resources from whatever the user does after invoking Bazel. This CL adds a startup option, --idle_server_tasks, to toggle the idle GC behavior.
Also, add some logging for when idle GC is enabled, so it's easier to evaluate its effects. Example of logging:
```
180718 17:43:04.609:I 247 [com.google.devtools.build.lib.server.IdleServerTasks.lambda$idle$0] [Idle GC] used: 157MB -> 15MB, committed: 421MB -> 422MB
```
Fixes https://github.com/bazelbuild/bazel/issues/5589.
Closes #5628.
PiperOrigin-RevId: 207869996
Diffstat (limited to 'src/main/cpp')
-rw-r--r-- | src/main/cpp/blaze.cc | 5 | ||||
-rw-r--r-- | src/main/cpp/startup_options.cc | 8 | ||||
-rw-r--r-- | src/main/cpp/startup_options.h | 2 |
3 files changed, 15 insertions, 0 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc index 9e7d979855..801a9314c0 100644 --- a/src/main/cpp/blaze.cc +++ b/src/main/cpp/blaze.cc @@ -541,6 +541,11 @@ static vector<string> GetArgumentArray( // being "null" to set the programmatic default in the server. result.push_back("--digest_function=" + globals->options->digest_function); } + if (globals->options->idle_server_tasks) { + result.push_back("--idle_server_tasks"); + } else { + result.push_back("--noidle_server_tasks"); + } if (globals->options->oom_more_eagerly) { result.push_back("--experimental_oom_more_eagerly"); } else { diff --git a/src/main/cpp/startup_options.cc b/src/main/cpp/startup_options.cc index a2d26b74d3..c54728f92e 100644 --- a/src/main/cpp/startup_options.cc +++ b/src/main/cpp/startup_options.cc @@ -93,6 +93,7 @@ StartupOptions::StartupOptions(const string &product_name, "com.google.devtools.build.lib.util.SingleLineFormatter"), expand_configs_in_place(true), digest_function(), + idle_server_tasks(true), original_startup_options_(std::vector<RcStartupFlag>()) { bool testing = !blaze::GetEnv("TEST_TMPDIR").empty(); if (testing) { @@ -133,6 +134,7 @@ StartupOptions::StartupOptions(const string &product_name, RegisterNullaryStartupFlag("experimental_oom_more_eagerly"); RegisterNullaryStartupFlag("fatal_event_bus_exceptions"); RegisterNullaryStartupFlag("host_jvm_debug"); + RegisterNullaryStartupFlag("idle_server_tasks"); RegisterNullaryStartupFlag("ignore_all_rc_files"); RegisterNullaryStartupFlag("watchfs"); RegisterNullaryStartupFlag("write_command_log"); @@ -334,6 +336,12 @@ blaze_exit_code::ExitCode StartupOptions::ProcessArg( } else if (GetNullaryOption(arg, "--noexpand_configs_in_place")) { expand_configs_in_place = false; option_sources["expand_configs_in_place"] = rcfile; + } else if (GetNullaryOption(arg, "--idle_server_tasks")) { + idle_server_tasks = true; + option_sources["idle_server_tasks"] = rcfile; + } else if (GetNullaryOption(arg, "--noidle_server_tasks")) { + idle_server_tasks = false; + option_sources["idle_server_tasks"] = rcfile; } else if ((value = GetUnaryOption(arg, next_arg, "--connect_timeout_secs")) != NULL) { if (!blaze_util::safe_strto32(value, &connect_timeout_secs) || diff --git a/src/main/cpp/startup_options.h b/src/main/cpp/startup_options.h index cca38369c3..9f4cd0c622 100644 --- a/src/main/cpp/startup_options.h +++ b/src/main/cpp/startup_options.h @@ -301,6 +301,8 @@ class StartupOptions { // The hash function to use when computing file digests. std::string digest_function; + bool idle_server_tasks; + // The startup options as received from the user and rc files, tagged with // their origin. This is populated by ProcessArgs. std::vector<RcStartupFlag> original_startup_options_; |