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

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

Issue 492763002: Move idle notification handling to GCIdleTimeHandler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Casts Created 6 years, 4 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 | « no previous file | src/heap/gc-idle-time-handler.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 #ifndef V8_HEAP_GC_IDLE_TIME_HANDLER_H_ 5 #ifndef V8_HEAP_GC_IDLE_TIME_HANDLER_H_
6 #define V8_HEAP_GC_IDLE_TIME_HANDLER_H_ 6 #define V8_HEAP_GC_IDLE_TIME_HANDLER_H_
7 7
8 #include "src/globals.h" 8 #include "src/globals.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 enum GCIdleTimeActionType {
14 DO_NOTHING,
15 DO_INCREMENTAL_MARKING,
16 DO_SCAVENGE,
17 DO_FULL_GC
18 };
19
20
21 class GCIdleTimeAction {
22 public:
23 static GCIdleTimeAction Nothing() {
24 GCIdleTimeAction result;
25 result.type = DO_NOTHING;
26 result.parameter = 0;
27 return result;
28 }
29 static GCIdleTimeAction IncrementalMarking(intptr_t step_size) {
30 GCIdleTimeAction result;
31 result.type = DO_INCREMENTAL_MARKING;
32 result.parameter = step_size;
33 return result;
34 }
35 static GCIdleTimeAction Scavenge() {
36 GCIdleTimeAction result;
37 result.type = DO_SCAVENGE;
38 result.parameter = 0;
39 return result;
40 }
41 static GCIdleTimeAction FullGC() {
42 GCIdleTimeAction result;
43 result.type = DO_FULL_GC;
44 result.parameter = 0;
45 return result;
46 }
47
48 GCIdleTimeActionType type;
49 intptr_t parameter;
50 };
51
52 class GCTracer;
53
13 // The idle time handler makes decisions about which garbage collection 54 // The idle time handler makes decisions about which garbage collection
14 // operations are executing during IdleNotification. 55 // operations are executing during IdleNotification.
15 class GCIdleTimeHandler { 56 class GCIdleTimeHandler {
16 public: 57 public:
17 static size_t EstimateMarkingStepSize(size_t idle_time_in_ms,
18 size_t marking_speed_in_bytes_per_ms);
19
20 // If we haven't recorded any incremental marking events yet, we carefully 58 // If we haven't recorded any incremental marking events yet, we carefully
21 // mark with a conservative lower bound for the marking speed. 59 // mark with a conservative lower bound for the marking speed.
22 static const size_t kInitialConservativeMarkingSpeed = 100 * KB; 60 static const size_t kInitialConservativeMarkingSpeed = 100 * KB;
23 61
24 // Maximum marking step size returned by EstimateMarkingStepSize. 62 // Maximum marking step size returned by EstimateMarkingStepSize.
25 static const size_t kMaximumMarkingStepSize = 700 * MB; 63 static const size_t kMaximumMarkingStepSize = 700 * MB;
26 64
27 // We have to make sure that we finish the IdleNotification before 65 // We have to make sure that we finish the IdleNotification before
28 // idle_time_in_ms. Hence, we conservatively prune our workload estimate. 66 // idle_time_in_ms. Hence, we conservatively prune our workload estimate.
29 static const double kConservativeTimeRatio; 67 static const double kConservativeTimeRatio;
30 68
69 // If we haven't recorded any mark-compact events yet, we use
70 // conservative lower bound for the mark-compact speed.
71 static const size_t kInitialConservativeMarkCompactSpeed = 2 * MB;
72
73 // Maximum mark-compact time returned by EstimateMarkCompactTime.
74 static const size_t kMaxMarkCompactTimeInMs;
75
76 GCIdleTimeHandler()
77 : mark_compacts_since_idle_round_started_(0),
78 scavenges_since_last_idle_round_(0) {}
79
80 GCIdleTimeAction Compute(int idle_time_in_ms, int contexts_disposed,
81 size_t size_of_objects,
82 bool incremental_marking_stopped,
83 GCTracer* gc_tracer);
84
85 void NotifyIdleMarkCompact() {
86 if (mark_compacts_since_idle_round_started_ < kMaxMarkCompactsInIdleRound) {
87 ++mark_compacts_since_idle_round_started_;
88 if (mark_compacts_since_idle_round_started_ ==
89 kMaxMarkCompactsInIdleRound) {
90 scavenges_since_last_idle_round_ = 0;
91 }
92 }
93 }
94
95 void NotifyScavenge() { ++scavenges_since_last_idle_round_; }
96
97 static size_t EstimateMarkingStepSize(size_t idle_time_in_ms,
98 size_t marking_speed_in_bytes_per_ms);
99
100 static size_t EstimateMarkCompactTime(
101 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms);
102
31 private: 103 private:
104 void StartIdleRound() { mark_compacts_since_idle_round_started_ = 0; }
105 bool IsIdleRoundFinished() {
106 return mark_compacts_since_idle_round_started_ ==
107 kMaxMarkCompactsInIdleRound;
108 }
109 bool EnoughGarbageSinceLastIdleRound() {
110 return scavenges_since_last_idle_round_ >= kIdleScavengeThreshold;
111 }
112
113 static const int kMaxMarkCompactsInIdleRound = 7;
114 static const int kIdleScavengeThreshold = 5;
115 int mark_compacts_since_idle_round_started_;
116 int scavenges_since_last_idle_round_;
117
32 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); 118 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler);
33 }; 119 };
34 120
35 } // namespace internal 121 } // namespace internal
36 } // namespace v8 122 } // namespace v8
37 123
38 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ 124 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | src/heap/gc-idle-time-handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698