Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Unified Diff: src/heap/memory-reducer.cc

Issue 1311993003: Reland "Make sure that memory reducer makes progress in incremental marking"" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/incremental-marking.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/memory-reducer.cc
diff --git a/src/heap/memory-reducer.cc b/src/heap/memory-reducer.cc
index 44088f2a79df870fdfb8bfc3876b0e87c92b6d13..115e376f2e223657aa2d35d5d4d9daedde300469 100644
--- a/src/heap/memory-reducer.cc
+++ b/src/heap/memory-reducer.cc
@@ -46,12 +46,35 @@ void MemoryReducer::NotifyTimer(const Event& event) {
if (state_.action == kRun) {
DCHECK(heap()->incremental_marking()->IsStopped());
DCHECK(FLAG_incremental_marking);
- heap()->StartIdleIncrementalMarking();
if (FLAG_trace_gc_verbose) {
PrintIsolate(heap()->isolate(), "Memory reducer: started GC #%d\n",
state_.started_gcs);
}
+ if (heap()->ShouldOptimizeForMemoryUsage()) {
+ // Do full GC if memory usage has higher priority than latency. This is
+ // important for background tabs that do not send idle notifications.
+ heap()->CollectAllGarbage(Heap::kReduceMemoryFootprintMask,
+ "memory reducer");
+ } else {
+ heap()->StartIdleIncrementalMarking();
+ }
} else if (state_.action == kWait) {
+ if (!heap()->incremental_marking()->IsStopped() &&
+ heap()->ShouldOptimizeForMemoryUsage()) {
+ // Make progress with pending incremental marking if memory usage has
+ // higher priority than latency. This is important for background tabs
+ // that do not send idle notifications.
+ const int kIncrementalMarkingDelayMs = 500;
+ double deadline = heap()->MonotonicallyIncreasingTimeInMs() +
+ kIncrementalMarkingDelayMs;
+ heap()->AdvanceIncrementalMarking(
+ 0, deadline, i::IncrementalMarking::StepActions(
+ i::IncrementalMarking::NO_GC_VIA_STACK_GUARD,
+ i::IncrementalMarking::FORCE_MARKING,
+ i::IncrementalMarking::FORCE_COMPLETION));
+ heap()->FinalizeIncrementalMarkingIfComplete(
+ "Memory reducer: finalize incremental marking");
+ }
// Re-schedule the timer.
ScheduleTimer(state_.next_gc_start_ms - event.time_ms);
if (FLAG_trace_gc_verbose) {
« no previous file with comments | « src/heap/incremental-marking.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698