From 91e3063d97b4dba239682d00ecfb3ea8c0a96539 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Tue, 25 Mar 2014 15:58:50 -0700 Subject: [PATCH] Add GC mode for stressing testing heap transitions. The stress testing mode does repeated heap transitions when the heap gets a process state update. In between each transition, the heap waits for a specified number of time. Change-Id: Ie3f43835e539fa8da147f77b4623a432a0d858c2 --- compiler/jni/quick/arm/calling_convention_arm.cc | 2 +- runtime/gc/heap.cc | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/jni/quick/arm/calling_convention_arm.cc b/compiler/jni/quick/arm/calling_convention_arm.cc index 9778293ee..78f403c2e 100644 --- a/compiler/jni/quick/arm/calling_convention_arm.cc +++ b/compiler/jni/quick/arm/calling_convention_arm.cc @@ -133,7 +133,7 @@ ArmJniCallingConvention::ArmJniCallingConvention(bool is_static, bool is_synchro uint32_t ArmJniCallingConvention::CoreSpillMask() const { // Compute spill mask to agree with callee saves initialized in the constructor uint32_t result = 0; - result = 1 << R5 | 1 << R6 | 1 << R7 | 1 << R8 | 1 << R10 | 1 << R11 | 1 << LR; + result = 1 << R5 | 1 << R6 | 1 << R7 | 1 << R8 | 1 << R10 | 1 << R11 | 1 << LR; return result; } diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index a256b6712..7827261b0 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -70,6 +70,8 @@ namespace art { namespace gc { +static constexpr size_t kCollectorTransitionStressIterations = 0; +static constexpr size_t kCollectorTransitionStressWait = 10 * 1000; // Microseconds static constexpr bool kGCALotMode = false; static constexpr size_t kGcAlotInterval = KB; // Minimum amount of remaining bytes before a concurrent GC is triggered. @@ -482,6 +484,13 @@ void Heap::DecrementDisableMovingGC(Thread* self) { void Heap::UpdateProcessState(ProcessState process_state) { if (process_state_ != process_state) { process_state_ = process_state; + for (size_t i = 1; i <= kCollectorTransitionStressIterations; ++i) { + // Start at index 1 to avoid "is always false" warning. + // Have iteration 1 always transition the collector. + TransitionCollector((((i & 1) == 1) == (process_state_ == kProcessStateJankPerceptible)) + ? post_zygote_collector_type_ : background_collector_type_); + usleep(kCollectorTransitionStressWait); + } if (process_state_ == kProcessStateJankPerceptible) { // Transition back to foreground right away to prevent jank. RequestCollectorTransition(post_zygote_collector_type_, 0); -- 2.11.0