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

Side by Side Diff: src/heap/memory-reducer.h

Issue 1213313004: Start incremental marking in long idle notification for background tab (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/memory-reducer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HEAP_memory_reducer_H 5 #ifndef V8_HEAP_memory_reducer_H
6 #define V8_HEAP_memory_reducer_H 6 #define V8_HEAP_memory_reducer_H
7 7
8 #include "include/v8-platform.h" 8 #include "include/v8-platform.h"
9 #include "src/base/macros.h" 9 #include "src/base/macros.h"
10 10
(...skipping 30 matching lines...) Expand all
41 // DONE -> WAIT 0 (now_ms + long_delay_ms) happens: 41 // DONE -> WAIT 0 (now_ms + long_delay_ms) happens:
42 // - on context disposal, 42 // - on context disposal,
43 // - at the end of mark-compact GC initiated by the mutator. 43 // - at the end of mark-compact GC initiated by the mutator.
44 // This signals that there is potential garbage to be collected. 44 // This signals that there is potential garbage to be collected.
45 // 45 //
46 // WAIT n x -> WAIT n (now_ms + long_delay_ms) happens: 46 // WAIT n x -> WAIT n (now_ms + long_delay_ms) happens:
47 // - on mark-compact GC initiated by the mutator, 47 // - on mark-compact GC initiated by the mutator,
48 // - in the timer callback if the mutator allocation rate is high or 48 // - in the timer callback if the mutator allocation rate is high or
49 // incremental GC is in progress. 49 // incremental GC is in progress.
50 // 50 //
51 // WAIT n x -> WAIT (n+1) happens:
52 // - on background idle notification, which signals that we can start
53 // incremental marking even if the allocation rate is high.
54 // The MemoryReducer starts incremental marking on this transition but still
55 // has a pending timer task.
56 //
57 // WAIT n x -> DONE happens:
58 // - in the timer callback if n >= kMaxNumberOfGCs.
59 //
51 // WAIT n x -> RUN (n+1) happens: 60 // WAIT n x -> RUN (n+1) happens:
52 // - in the timer callback if the mutator allocation rate is low 61 // - in the timer callback if the mutator allocation rate is low
53 // and now_ms >= x and there is no incremental GC in progress. 62 // and now_ms >= x and there is no incremental GC in progress.
54 // The MemoryReducer starts incremental marking on this transition. 63 // The MemoryReducer starts incremental marking on this transition.
55 // 64 //
56 // RUN n -> DONE happens: 65 // RUN n -> DONE happens:
57 // - at end of the incremental GC initiated by the MemoryReducer if 66 // - at end of the incremental GC initiated by the MemoryReducer if
58 // (n > 1 and there is no more garbage to be collected) or 67 // (n > 1 and there is no more garbage to be collected) or
59 // n == kMaxNumberOfGCs. 68 // n == kMaxNumberOfGCs.
60 // RUN n -> WAIT n (now_ms + short_delay_ms) happens: 69 // RUN n -> WAIT n (now_ms + short_delay_ms) happens:
(...skipping 13 matching lines...) Expand all
74 next_gc_start_ms(next_gc_start_ms) {} 83 next_gc_start_ms(next_gc_start_ms) {}
75 Action action; 84 Action action;
76 int started_gcs; 85 int started_gcs;
77 double next_gc_start_ms; 86 double next_gc_start_ms;
78 }; 87 };
79 88
80 enum EventType { 89 enum EventType {
81 kTimer, 90 kTimer,
82 kMarkCompact, 91 kMarkCompact,
83 kContextDisposed, 92 kContextDisposed,
93 kBackgroundIdleNotification
84 }; 94 };
85 95
86 struct Event { 96 struct Event {
87 EventType type; 97 EventType type;
88 double time_ms; 98 double time_ms;
89 bool low_allocation_rate; 99 bool low_allocation_rate;
90 bool next_gc_likely_to_collect_more; 100 bool next_gc_likely_to_collect_more;
91 bool can_start_incremental_gc; 101 bool can_start_incremental_gc;
92 }; 102 };
93 103
94 explicit MemoryReducer(Heap* heap) : heap_(heap), state_(kDone, 0, 0.0) {} 104 explicit MemoryReducer(Heap* heap) : heap_(heap), state_(kDone, 0, 0.0) {}
95 // Callbacks. 105 // Callbacks.
96 void NotifyTimer(const Event& event); 106 void NotifyTimer(const Event& event);
97 void NotifyMarkCompact(const Event& event); 107 void NotifyMarkCompact(const Event& event);
98 void NotifyScavenge(const Event& event);
99 void NotifyContextDisposed(const Event& event); 108 void NotifyContextDisposed(const Event& event);
109 void NotifyBackgroundIdleNotification(const Event& event);
100 // The step function that computes the next state from the current state and 110 // The step function that computes the next state from the current state and
101 // the incoming event. 111 // the incoming event.
102 static State Step(const State& state, const Event& event); 112 static State Step(const State& state, const Event& event);
103 // Posts a timer task that will call NotifyTimer after the given delay. 113 // Posts a timer task that will call NotifyTimer after the given delay.
104 void ScheduleTimer(double delay_ms); 114 void ScheduleTimer(double delay_ms);
105 115
106 static const int kLongDelayMs; 116 static const int kLongDelayMs;
107 static const int kShortDelayMs; 117 static const int kShortDelayMs;
108 static const int kMaxNumberOfGCs; 118 static const int kMaxNumberOfGCs;
109 119
(...skipping 16 matching lines...) Expand all
126 Heap* heap_; 136 Heap* heap_;
127 State state_; 137 State state_;
128 138
129 DISALLOW_COPY_AND_ASSIGN(MemoryReducer); 139 DISALLOW_COPY_AND_ASSIGN(MemoryReducer);
130 }; 140 };
131 141
132 } // namespace internal 142 } // namespace internal
133 } // namespace v8 143 } // namespace v8
134 144
135 #endif // V8_HEAP_memory_reducer_H 145 #endif // V8_HEAP_memory_reducer_H
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/memory-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698