summaryrefslogtreecommitdiffstats
path: root/runtime/gc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2014-03-25 15:58:50 -0700
committerMathieu Chartier <mathieuc@google.com>2014-03-25 16:25:26 -0700
commit91e3063d97b4dba239682d00ecfb3ea8c0a96539 (patch)
tree1ccb6b866a61596efb0b9931f687ecca67742a14 /runtime/gc
parentc92492fc2565515ac5d68a8443efa91ba189b404 (diff)
downloadart-91e3063d97b4dba239682d00ecfb3ea8c0a96539.zip
art-91e3063d97b4dba239682d00ecfb3ea8c0a96539.tar.gz
art-91e3063d97b4dba239682d00ecfb3ea8c0a96539.tar.bz2
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
Diffstat (limited to 'runtime/gc')
-rw-r--r--runtime/gc/heap.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index a256b67..7827261 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);