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

Side by Side Diff: src/heap/gc-idle-time-handler.cc

Issue 573943004: Use allocation throughput to estimate next scavenge event in idle notification. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | src/heap/gc-idle-time-handler-unittest.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #include "src/heap/gc-idle-time-handler.h" 5 #include "src/heap/gc-idle-time-handler.h"
6 #include "src/heap/gc-tracer.h" 6 #include "src/heap/gc-tracer.h"
7 #include "src/utils.h" 7 #include "src/utils.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 size_t GCIdleTimeHandler::EstimateScavengeTime( 74 size_t GCIdleTimeHandler::EstimateScavengeTime(
75 size_t new_space_size, size_t scavenge_speed_in_bytes_per_ms) { 75 size_t new_space_size, size_t scavenge_speed_in_bytes_per_ms) {
76 if (scavenge_speed_in_bytes_per_ms == 0) { 76 if (scavenge_speed_in_bytes_per_ms == 0) {
77 scavenge_speed_in_bytes_per_ms = kInitialConservativeScavengeSpeed; 77 scavenge_speed_in_bytes_per_ms = kInitialConservativeScavengeSpeed;
78 } 78 }
79 return new_space_size / scavenge_speed_in_bytes_per_ms; 79 return new_space_size / scavenge_speed_in_bytes_per_ms;
80 } 80 }
81 81
82 82
83 bool GCIdleTimeHandler::ScavangeMayHappenSoon(
84 size_t available_new_space_memory,
85 size_t new_space_allocation_throughput_in_bytes_per_ms) {
86 if (available_new_space_memory <=
87 new_space_allocation_throughput_in_bytes_per_ms *
88 kMaxFrameRenderingIdleTime) {
89 return true;
90 }
91 return false;
92 }
93
94
83 // The following logic is implemented by the controller: 95 // The following logic is implemented by the controller:
84 // (1) If the new space is almost full and we can effort a Scavenge, then a 96 // (1) If the new space is almost full and we can effort a Scavenge, then a
85 // Scavenge is performed. 97 // Scavenge is performed.
86 // (2) If there is currently no MarkCompact idle round going on, we start a 98 // (2) If there is currently no MarkCompact idle round going on, we start a
87 // new idle round if enough garbage was created or we received a context 99 // new idle round if enough garbage was created or we received a context
88 // disposal event. Otherwise we do not perform garbage collection to keep 100 // disposal event. Otherwise we do not perform garbage collection to keep
89 // system utilization low. 101 // system utilization low.
90 // (3) If incremental marking is done, we perform a full garbage collection 102 // (3) If incremental marking is done, we perform a full garbage collection
91 // if context was disposed or if we are allowed to still do full garbage 103 // if context was disposed or if we are allowed to still do full garbage
92 // collections during this idle round or if we are not allowed to start 104 // collections during this idle round or if we are not allowed to start
93 // incremental marking. Otherwise we do not perform garbage collection to 105 // incremental marking. Otherwise we do not perform garbage collection to
94 // keep system utilization low. 106 // keep system utilization low.
95 // (4) If sweeping is in progress and we received a large enough idle time 107 // (4) If sweeping is in progress and we received a large enough idle time
96 // request, we finalize sweeping here. 108 // request, we finalize sweeping here.
97 // (5) If incremental marking is in progress, we perform a marking step. Note, 109 // (5) If incremental marking is in progress, we perform a marking step. Note,
98 // that this currently may trigger a full garbage collection. 110 // that this currently may trigger a full garbage collection.
99 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, 111 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms,
100 HeapState heap_state) { 112 HeapState heap_state) {
101 if (heap_state.available_new_space_memory < kNewSpaceAlmostFullTreshold && 113 if (ScavangeMayHappenSoon(
114 heap_state.available_new_space_memory,
115 heap_state.new_space_allocation_throughput_in_bytes_per_ms) &&
102 idle_time_in_ms >= 116 idle_time_in_ms >=
103 EstimateScavengeTime(heap_state.new_space_capacity, 117 EstimateScavengeTime(heap_state.new_space_capacity,
104 heap_state.scavenge_speed_in_bytes_per_ms)) { 118 heap_state.scavenge_speed_in_bytes_per_ms)) {
105 return GCIdleTimeAction::Scavenge(); 119 return GCIdleTimeAction::Scavenge();
106 } 120 }
107 if (IsMarkCompactIdleRoundFinished()) { 121 if (IsMarkCompactIdleRoundFinished()) {
108 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) { 122 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) {
109 StartIdleRound(); 123 StartIdleRound();
110 } else { 124 } else {
111 return GCIdleTimeAction::Done(); 125 return GCIdleTimeAction::Done();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (heap_state.incremental_marking_stopped && 160 if (heap_state.incremental_marking_stopped &&
147 !heap_state.can_start_incremental_marking) { 161 !heap_state.can_start_incremental_marking) {
148 return GCIdleTimeAction::Nothing(); 162 return GCIdleTimeAction::Nothing();
149 } 163 }
150 size_t step_size = EstimateMarkingStepSize( 164 size_t step_size = EstimateMarkingStepSize(
151 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms); 165 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms);
152 return GCIdleTimeAction::IncrementalMarking(step_size); 166 return GCIdleTimeAction::IncrementalMarking(step_size);
153 } 167 }
154 } 168 }
155 } 169 }
OLDNEW
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | src/heap/gc-idle-time-handler-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698