diff options
author | 2021-05-07 17:34:51 -0700 | |
---|---|---|
committer | 2021-05-09 18:33:57 +0000 | |
commit | bcec38f7b7dc92d89ce9d49b8c1ba9afe87dab6b (patch) | |
tree | 672ac33f3e719b67f4eb29525c5620fdd186305d | |
parent | c256028e1fb92b47c741db67b6bc8ca6995e6c1b (diff) |
Do not sleep while waiting for GC
This is a partial revert of aosp/1690649. It backs out the
addition of the wait loop in CheckGCForNative().
We can apparently still encounter cases in which we sleep for a
nonexistent GC.
Test: Build and boot AOSP
Bug: 187531176
Bug: 186592536
Change-Id: Icaf75ae3582ea51eecf9fe4b81e629bc1d862788
-rw-r--r-- | runtime/gc/heap.cc | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 208ce13c60..93b1bcf7ed 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -3965,20 +3965,7 @@ inline void Heap::CheckGCForNative(Thread* self) { if (VLOG_IS_ON(heap) || VLOG_IS_ON(startup)) { LOG(INFO) << "Stopping for native allocation, urgency: " << gc_urgency; } - // Count how many times we do this, so we can warn if this becomes excessive. - // Stop after a while out of excessive caution. - static constexpr int kGcWaitIters = 20; - for (int i = 1; i <= kGcWaitIters; ++i) { - if (!GCNumberLt(GetCurrentGcNum(), gcs_requested_.load(std::memory_order_relaxed)) - || WaitForGcToComplete(kGcCauseForNativeAlloc, self) != collector::kGcTypeNone) { - break; - } - if (i % 10 == 0) { - LOG(WARNING) << "Slept " << i << " times in native allocation, waiting for GC"; - } - static constexpr int kGcWaitSleepMicros = 2000; - usleep(kGcWaitSleepMicros); // Encourage our requested GC to start. - } + WaitForGcToComplete(kGcCauseForNativeAlloc, self); } } else { CollectGarbageInternal(NonStickyGcType(), kGcCauseForNativeAlloc, false, starting_gc_num + 1); |