OSDN Git Service

Add GC mode for stressing testing heap transitions.
authorMathieu Chartier <mathieuc@google.com>
Tue, 25 Mar 2014 22:58:50 +0000 (15:58 -0700)
committerMathieu Chartier <mathieuc@google.com>
Tue, 25 Mar 2014 23:25:26 +0000 (16:25 -0700)
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
runtime/gc/heap.cc

index 9778293..78f403c 100644 (file)
@@ -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;
 }
 
index a256b67..7827261 100644 (file)
@@ -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);