Add more runtime options.
Changed HeapGCThreads to be split into two different options:
-XX:ParallelGCThreads: Which specifies how many threads the GC may
use when the mutators are suspended.
-XX:ConcGCThreads: Which specifies how many threads the GC may use
when the mutators are running.
Added runtime options to specify long pause / long GC thresholds:
-XX:LongPauseThreshold (default 5ms)
-XX:LongGCThreshold (default 100ms)
These thresholds were previously constants, but are now runtime
options. If we exceed either of the thresholds, we print the GC
message.
Added a new runtime option: -XX:IgnoreMaxFootprint which makes it
that the GC only does GC when the number of bytes allocated hits
the growth limit. This causes GC to occur much less frequently and
can be useful to measure how much of an impact GC has on performance.
Changed the GC behaviour to use only one thread when we do not care
about pauses to prevent jank that can be caused by 2 simultaneous GC
on different processes fighting for CPU time.
Added thread pool functionality for changing the maximum number of
active workers.
Fixed an accounting error where we didn't count large objects in the
total freed.
Bug: 9986416
Change-Id: I86afa358d93dcd3780e18ac5d85bdb1a130cb7e7
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index c4a9503..31800ce 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -339,7 +339,9 @@
parsed->heap_target_utilization_ = gc::Heap::kDefaultTargetUtilization;
parsed->heap_growth_limit_ = 0; // 0 means no growth limit.
// Default to number of processors minus one since the main GC thread also does work.
- parsed->heap_gc_threads_ = sysconf(_SC_NPROCESSORS_CONF) - 1;
+ parsed->parallel_gc_threads_ = sysconf(_SC_NPROCESSORS_CONF) - 1;
+ // Only the main GC thread, no workers.
+ parsed->conc_gc_threads_ = 0;
parsed->stack_size_ = 0; // 0 means default.
parsed->low_memory_mode_ = false;
@@ -349,6 +351,10 @@
parsed->is_concurrent_gc_enabled_ = true;
parsed->is_explicit_gc_disabled_ = false;
+ parsed->long_pause_log_threshold_ = gc::Heap::kDefaultLongPauseLogThreshold;
+ parsed->long_gc_log_threshold_ = gc::Heap::kDefaultLongGCLogThreshold;
+ parsed->ignore_max_footprint_ = false;
+
parsed->lock_profiling_threshold_ = 0;
parsed->hook_is_sensitive_thread_ = NULL;
@@ -480,9 +486,12 @@
return NULL;
}
parsed->heap_target_utilization_ = value;
- } else if (StartsWith(option, "-XX:HeapGCThreads=")) {
- parsed->heap_gc_threads_ =
- ParseMemoryOption(option.substr(strlen("-XX:HeapGCThreads=")).c_str(), 1024);
+ } else if (StartsWith(option, "-XX:ParallelGCThreads=")) {
+ parsed->parallel_gc_threads_ =
+ ParseMemoryOption(option.substr(strlen("-XX:ParallelGCThreads=")).c_str(), 1024);
+ } else if (StartsWith(option, "-XX:ConcGCThreads=")) {
+ parsed->conc_gc_threads_ =
+ ParseMemoryOption(option.substr(strlen("-XX:ConcGCThreads=")).c_str(), 1024);
} else if (StartsWith(option, "-Xss")) {
size_t size = ParseMemoryOption(option.substr(strlen("-Xss")).c_str(), 1);
if (size == 0) {
@@ -494,6 +503,14 @@
return NULL;
}
parsed->stack_size_ = size;
+ } else if (option == "-XX:LongPauseLogThreshold") {
+ parsed->long_pause_log_threshold_ =
+ ParseMemoryOption(option.substr(strlen("-XX:LongPauseLogThreshold=")).c_str(), 1024);
+ } else if (option == "-XX:LongGCLogThreshold") {
+ parsed->long_gc_log_threshold_ =
+ ParseMemoryOption(option.substr(strlen("-XX:LongGCLogThreshold")).c_str(), 1024);
+ } else if (option == "-XX:IgnoreMaxFootprint") {
+ parsed->ignore_max_footprint_ = true;
} else if (option == "-XX:LowMemoryMode") {
parsed->low_memory_mode_ = true;
} else if (StartsWith(option, "-D")) {
@@ -865,8 +882,12 @@
options->heap_maximum_size_,
options->image_,
options->is_concurrent_gc_enabled_,
- options->heap_gc_threads_,
- options->low_memory_mode_);
+ options->parallel_gc_threads_,
+ options->conc_gc_threads_,
+ options->low_memory_mode_,
+ options->long_pause_log_threshold_,
+ options->long_gc_log_threshold_,
+ options->ignore_max_footprint_);
BlockSignals();
InitPlatformSignalHandlers();