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

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

Issue 563493002: Allow IdleNotification to trigger Scavenges. (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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 size_t GCIdleTimeHandler::EstimateMarkCompactTime( 61 size_t GCIdleTimeHandler::EstimateMarkCompactTime(
62 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms) { 62 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms) {
63 if (mark_compact_speed_in_bytes_per_ms == 0) { 63 if (mark_compact_speed_in_bytes_per_ms == 0) {
64 mark_compact_speed_in_bytes_per_ms = kInitialConservativeMarkCompactSpeed; 64 mark_compact_speed_in_bytes_per_ms = kInitialConservativeMarkCompactSpeed;
65 } 65 }
66 size_t result = size_of_objects / mark_compact_speed_in_bytes_per_ms; 66 size_t result = size_of_objects / mark_compact_speed_in_bytes_per_ms;
67 return Min(result, kMaxMarkCompactTimeInMs); 67 return Min(result, kMaxMarkCompactTimeInMs);
68 } 68 }
69 69
70 70
71 size_t GCIdleTimeHandler::EstimateScavengeTime(
72 size_t new_space_size, size_t scavenge_speed_in_bytes_per_ms) {
73 if (scavenge_speed_in_bytes_per_ms == 0) {
74 scavenge_speed_in_bytes_per_ms = kInitialConservativeScavengeSpeed;
75 }
76 return new_space_size / scavenge_speed_in_bytes_per_ms;
77 }
78
79
80 // The following logic is implemented by the controller:
81 // (1) If the new space is almost full and we can effort a Scavenge, then a
82 // Scavenge is performed.
83 // (2) If there is currently no MarkCompact idle round going on, we start a
84 // new idle round if enough garbage was created or we received a context
85 // disposal event. Otherwise we do not perform garbage collection to keep
86 // system utilization low.
87 // (3) If incremental marking is done, we perform a full garbage collection
88 // if context was disposed or if we are allowed to still do full garbage
89 // collections during this idle round or if we are not allowed to start
90 // incremental marking. Otherwise we do not perform garbage collection to
91 // keep system utilization low.
92 // (4) If sweeping is in progress and we received a large enough idle time
93 // request, we finalize sweeping here.
94 // (5) If incremental marking is in progress, we perform a marking step. Note,
95 // that this currently may trigger a full garbage collection.
71 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, 96 GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms,
72 HeapState heap_state) { 97 HeapState heap_state) {
73 if (IsIdleRoundFinished()) { 98 if (heap_state.available_new_space_memory < kNewSpaceAlmostFullTreshold &&
99 idle_time_in_ms >=
100 EstimateScavengeTime(heap_state.new_space_capacity,
101 heap_state.scavenge_speed_in_bytes_per_ms)) {
102 return GCIdleTimeAction::Scavenge();
103 }
104 if (IsMarkCompactIdleRoundFinished()) {
74 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) { 105 if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) {
75 StartIdleRound(); 106 StartIdleRound();
76 } else { 107 } else {
77 return GCIdleTimeAction::Nothing(); 108 return GCIdleTimeAction::Nothing();
78 } 109 }
79 } 110 }
80 if (heap_state.incremental_marking_stopped) { 111 if (heap_state.incremental_marking_stopped) {
81 if (idle_time_in_ms >= EstimateMarkCompactTime( 112 if (idle_time_in_ms >= EstimateMarkCompactTime(
82 heap_state.size_of_objects, 113 heap_state.size_of_objects,
83 heap_state.mark_compact_speed_in_bytes_per_ms)) { 114 heap_state.mark_compact_speed_in_bytes_per_ms)) {
(...skipping 18 matching lines...) Expand all
102 idle_time_in_ms >= kMinTimeForFinalizeSweeping) { 133 idle_time_in_ms >= kMinTimeForFinalizeSweeping) {
103 return GCIdleTimeAction::FinalizeSweeping(); 134 return GCIdleTimeAction::FinalizeSweeping();
104 } 135 }
105 136
106 size_t step_size = EstimateMarkingStepSize( 137 size_t step_size = EstimateMarkingStepSize(
107 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms); 138 idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms);
108 return GCIdleTimeAction::IncrementalMarking(step_size); 139 return GCIdleTimeAction::IncrementalMarking(step_size);
109 } 140 }
110 } 141 }
111 } 142 }
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