Add developer option for dumping GC cumulative timings on shutdown.
The option is "-XX:DumpGCPerformanceOnShutdown".
Bug: 9986416
Change-Id: If6ebb26b3e611a9dead197740dbfc64e548dc388
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 33e6bfd..24ee31c 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -69,7 +69,6 @@
static constexpr bool kGCALotMode = false;
static constexpr size_t kGcAlotInterval = KB;
-static constexpr bool kDumpGcPerformanceOnShutdown = false;
// Minimum amount of remaining bytes before a concurrent GC is triggered.
static constexpr size_t kMinConcurrentRemainingBytes = 128 * KB;
static constexpr AllocatorType kDefaultPreZygoteAllocator = kAllocatorTypeFreeList;
@@ -79,7 +78,7 @@
double target_utilization, size_t capacity, const std::string& image_file_name,
bool concurrent_gc, size_t parallel_gc_threads, size_t conc_gc_threads,
bool low_memory_mode, size_t long_pause_log_threshold, size_t long_gc_log_threshold,
- bool ignore_max_footprint)
+ bool dump_gc_performance_on_shutdown, bool ignore_max_footprint)
: non_moving_space_(nullptr),
concurrent_gc_(concurrent_gc),
parallel_gc_threads_(parallel_gc_threads),
@@ -87,6 +86,7 @@
low_memory_mode_(low_memory_mode),
long_pause_log_threshold_(long_pause_log_threshold),
long_gc_log_threshold_(long_gc_log_threshold),
+ dump_gc_performance_on_shutdown_(dump_gc_performance_on_shutdown),
ignore_max_footprint_(ignore_max_footprint),
have_zygote_space_(false),
soft_reference_queue_(this),
@@ -610,7 +610,7 @@
Heap::~Heap() {
VLOG(heap) << "Starting ~Heap()";
- if (kDumpGcPerformanceOnShutdown) {
+ if (dump_gc_performance_on_shutdown_) {
DumpGcPerformanceInfo(LOG(INFO));
}
STLDeleteElements(&garbage_collectors_);
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 9215556..30b7eb1 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -145,7 +145,8 @@
size_t max_free, double target_utilization, size_t capacity,
const std::string& original_image_file_name, bool concurrent_gc,
size_t parallel_gc_threads, size_t conc_gc_threads, bool low_memory_mode,
- size_t long_pause_threshold, size_t long_gc_threshold, bool ignore_max_footprint);
+ size_t long_pause_threshold, size_t long_gc_threshold,
+ bool dump_gc_performance_on_shutdown, bool ignore_max_footprint);
~Heap();
@@ -647,6 +648,9 @@
// If we get a GC longer than long GC log threshold, then we print out the GC after it finishes.
const size_t long_gc_log_threshold_;
+ // If true, then we dump the GC cumulative timings on shutdown.
+ const bool dump_gc_performance_on_shutdown_;
+
// If we ignore the max footprint it lets the heap grow until it hits the heap capacity, this is
// useful for benchmarking since it reduces time spent in GC to a low %.
const bool ignore_max_footprint_;
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 08c0ba0..71ad252 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -368,6 +368,7 @@
parsed->long_pause_log_threshold_ = gc::Heap::kDefaultLongPauseLogThreshold;
parsed->long_gc_log_threshold_ = gc::Heap::kDefaultLongGCLogThreshold;
+ parsed->dump_gc_performance_on_shutdown_ = false;
parsed->ignore_max_footprint_ = false;
parsed->lock_profiling_threshold_ = 0;
@@ -528,6 +529,8 @@
} else if (option == "-XX:LongGCLogThreshold") {
parsed->long_gc_log_threshold_ =
ParseMemoryOption(option.substr(strlen("-XX:LongGCLogThreshold")).c_str(), 1024);
+ } else if (option == "-XX:DumpGCPerformanceOnShutdown") {
+ parsed->dump_gc_performance_on_shutdown_ = true;
} else if (option == "-XX:IgnoreMaxFootprint") {
parsed->ignore_max_footprint_ = true;
} else if (option == "-XX:LowMemoryMode") {
@@ -912,6 +915,7 @@
options->low_memory_mode_,
options->long_pause_log_threshold_,
options->long_gc_log_threshold_,
+ options->dump_gc_performance_on_shutdown_,
options->ignore_max_footprint_);
BlockSignals();
diff --git a/runtime/runtime.h b/runtime/runtime.h
index d025d47..d5ad299 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -103,6 +103,7 @@
bool is_explicit_gc_disabled_;
size_t long_pause_log_threshold_;
size_t long_gc_log_threshold_;
+ bool dump_gc_performance_on_shutdown_;
bool ignore_max_footprint_;
size_t heap_initial_size_;
size_t heap_maximum_size_;