summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/gc/heap.cc4
-rw-r--r--runtime/gc/heap.h5
-rw-r--r--runtime/parsed_options.cc5
-rw-r--r--runtime/runtime.cc1
-rw-r--r--runtime/runtime_options.def1
-rwxr-xr-xtools/run-libcore-tests.sh3
6 files changed, 18 insertions, 1 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index d6c1397795..d1a5014a6c 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -230,6 +230,7 @@ Heap::Heap(size_t initial_size,
size_t long_pause_log_threshold,
size_t long_gc_log_threshold,
bool ignore_target_footprint,
+ bool always_log_explicit_gcs,
bool use_tlab,
bool verify_pre_gc_heap,
bool verify_pre_sweeping_heap,
@@ -265,6 +266,7 @@ Heap::Heap(size_t initial_size,
pre_gc_weighted_allocated_bytes_(0.0),
post_gc_weighted_allocated_bytes_(0.0),
ignore_target_footprint_(ignore_target_footprint),
+ always_log_explicit_gcs_(always_log_explicit_gcs),
zygote_creation_lock_("zygote creation lock", kZygoteCreationLock),
zygote_space_(nullptr),
large_object_threshold_(large_object_threshold),
@@ -2699,7 +2701,7 @@ void Heap::LogGC(GcCause gc_cause, collector::GarbageCollector* collector) {
const std::vector<uint64_t>& pause_times = GetCurrentGcIteration()->GetPauseTimes();
// Print the GC if it is an explicit GC (e.g. Runtime.gc()) or a slow GC
// (mutator time blocked >= long_pause_log_threshold_).
- bool log_gc = kLogAllGCs || gc_cause == kGcCauseExplicit;
+ bool log_gc = kLogAllGCs || (gc_cause == kGcCauseExplicit && always_log_explicit_gcs_);
if (!log_gc && CareAboutPauseTimes()) {
// GC for alloc pauses the allocating thread, so consider it as a pause.
log_gc = duration > long_gc_log_threshold_ ||
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 57ae7c9ec9..fdcb0ad423 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -211,6 +211,7 @@ class Heap {
size_t long_pause_threshold,
size_t long_gc_threshold,
bool ignore_target_footprint,
+ bool always_log_explicit_gcs,
bool use_tlab,
bool verify_pre_gc_heap,
bool verify_pre_sweeping_heap,
@@ -1305,6 +1306,10 @@ class Heap {
// is useful for benchmarking since it reduces time spent in GC to a low %.
const bool ignore_target_footprint_;
+ // If we are running tests or some other configurations we might not actually
+ // want logs for explicit gcs since they can get spammy.
+ const bool always_log_explicit_gcs_;
+
// Lock which guards zygote space creation.
Mutex zygote_creation_lock_;
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index dab0f55df8..7fef0990b8 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -219,6 +219,11 @@ std::unique_ptr<RuntimeParser> ParsedOptions::MakeParser(bool ignore_unrecognize
.IntoKey(M::DumpJITInfoOnShutdown)
.Define("-XX:IgnoreMaxFootprint")
.IntoKey(M::IgnoreMaxFootprint)
+ .Define("-XX:AlwaysLogExplicitGcs:_")
+ .WithHelp("Allows one to control the logging of explicit GCs. Defaults to 'true'")
+ .WithType<bool>()
+ .WithValueMap({{"false", false}, {"true", true}})
+ .IntoKey(M::AlwaysLogExplicitGcs)
.Define("-XX:UseTLAB")
.WithValue(true)
.IntoKey(M::UseTLAB)
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 79b51daff7..c1141ecf71 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1411,6 +1411,7 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) {
runtime_options.GetOrDefault(Opt::LongPauseLogThreshold),
runtime_options.GetOrDefault(Opt::LongGCLogThreshold),
runtime_options.Exists(Opt::IgnoreMaxFootprint),
+ runtime_options.GetOrDefault(Opt::AlwaysLogExplicitGcs),
runtime_options.GetOrDefault(Opt::UseTLAB),
xgc_option.verify_pre_gc_heap_,
xgc_option.verify_pre_sweeping_heap_,
diff --git a/runtime/runtime_options.def b/runtime/runtime_options.def
index ce5a16b125..676ddd8c2b 100644
--- a/runtime/runtime_options.def
+++ b/runtime/runtime_options.def
@@ -71,6 +71,7 @@ RUNTIME_OPTIONS_KEY (Unit, DumpRegionInfoBeforeGC)
RUNTIME_OPTIONS_KEY (Unit, DumpRegionInfoAfterGC)
RUNTIME_OPTIONS_KEY (Unit, DumpJITInfoOnShutdown)
RUNTIME_OPTIONS_KEY (Unit, IgnoreMaxFootprint)
+RUNTIME_OPTIONS_KEY (bool, AlwaysLogExplicitGcs, true)
RUNTIME_OPTIONS_KEY (Unit, LowMemoryMode)
RUNTIME_OPTIONS_KEY (bool, UseTLAB, (kUseTlab || kUseReadBarrier))
RUNTIME_OPTIONS_KEY (bool, EnableHSpaceCompactForOOM, true)
diff --git a/tools/run-libcore-tests.sh b/tools/run-libcore-tests.sh
index f7c8e27853..4a793889de 100755
--- a/tools/run-libcore-tests.sh
+++ b/tools/run-libcore-tests.sh
@@ -270,6 +270,9 @@ if [ $execution_mode = "device" -o $execution_mode = "host" ]; then
# Add timeout to vogar command-line.
vogar_args="$vogar_args --timeout $timeout_secs"
+ # Suppress explicit gc logs that are triggered an absurd number of times by these tests.
+ vogar_args="$vogar_args --vm-arg -XX:AlwaysLogExplicitGcs:false"
+
# set the toolchain to use.
vogar_args="$vogar_args --toolchain d8 --language CUR"