ART: Only stress background transition in slow-debug
To lighten the load when starting new processes, by default keep
the wait time until running background compaction.
Bug: 35644369
Test: m test-art-host
Change-Id: I932684b02f3095bc011e5e8346eea103e458bfc5
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 67e8a0d..7328063 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -93,6 +93,9 @@
static constexpr size_t kCollectorTransitionStressIterations = 0;
static constexpr size_t kCollectorTransitionStressWait = 10 * 1000; // Microseconds
+
+DEFINE_RUNTIME_DEBUG_FLAG(Heap, kStressCollectorTransition);
+
// Minimum amount of remaining bytes before a concurrent GC is triggered.
static constexpr size_t kMinConcurrentRemainingBytes = 128 * KB;
static constexpr size_t kMaxConcurrentRemainingBytes = 512 * KB;
@@ -889,7 +892,9 @@
// the collector. Similarly, we invoke a full compaction for kCollectorTypeCC but don't
// transition the collector.
RequestCollectorTransition(background_collector_type_,
- kIsDebugBuild ? 0 : kCollectorTransitionWait);
+ kStressCollectorTransition
+ ? 0
+ : kCollectorTransitionWait);
}
}
}
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index d673b4a..7b4fab6 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -25,6 +25,7 @@
#include "allocator_type.h"
#include "arch/instruction_set.h"
#include "atomic.h"
+#include "base/logging.h"
#include "base/mutex.h"
#include "base/time_utils.h"
#include "gc/collector/gc_type.h"
@@ -155,6 +156,9 @@
static constexpr uint64_t kHeapTrimWait = MsToNs(5000);
// How long we wait after a transition request to perform a collector transition (nanoseconds).
static constexpr uint64_t kCollectorTransitionWait = MsToNs(5000);
+ // Whether the transition-wait applies or not. Zero wait will stress the
+ // transition code and collector, but increases jank probability.
+ DECLARE_RUNTIME_DEBUG_FLAG(kStressCollectorTransition);
// Create a heap with the requested sizes. The possible empty
// image_file_names names specify Spaces to load based on