Improve Transition GC initiation by removing the 5s delay
Once an app transitions to cached state and the runtime is updated, a
transition GC should immediately be requested without the 5s delay.
This allows the GC to execute before the app gets frozen and removes the
not needed 5s delay.
Test: Local testing
Bug: 272381448
Change-Id: I5197c1367c4c4c841af6de666e94276fcba0d85c
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 99b0c11..3b7f0e8 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -1102,15 +1102,11 @@
RequestCollectorTransition(foreground_collector_type_, 0);
GrowHeapOnJankPerceptibleSwitch();
} else {
- // Don't delay for debug builds since we may want to stress test the GC.
// If background_collector_type_ is kCollectorTypeHomogeneousSpaceCompact then we have
// special handling which does a homogenous space compaction once but then doesn't transition
// the collector. Similarly, we invoke a full compaction for kCollectorTypeCC but don't
// transition the collector.
- RequestCollectorTransition(background_collector_type_,
- kStressCollectorTransition
- ? 0
- : kCollectorTransitionWait);
+ RequestCollectorTransition(background_collector_type_, 0);
}
}
}
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 977c632..31a1b2b 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -182,10 +182,8 @@
// How often we allow heap trimming to happen (nanoseconds).
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.
+ // Whether the transition-GC heap threshold condition applies or not for non-low memory devices.
+ // Stressing GC will bypass the heap threshold condition.
DECLARE_RUNTIME_DEBUG_FLAG(kStressCollectorTransition);
// Create a heap with the requested sizes. The possible empty