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

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: Remove base embedded 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') | src/heap/gc-idle-time-handler.cc » ('J')
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 GCIdleTimeHandler()
70 : mark_compacts_since_idle_round_started_(0),
71 scavenges_since_last_idle_round_(0) {}
72
73 GCIdleTimeAction Compute(int idle_time_in_ms, int contexts_disposed,
74 intptr_t size_of_objects,
75 bool incremental_marking_stopped,
76 GCTracer* gc_tracer);
77
78 void NotifyIdleMarkCompact() {
79 if (mark_compacts_since_idle_round_started_ < kMaxMarkCompactsInIdleRound) {
80 ++mark_compacts_since_idle_round_started_;
81 if (mark_compacts_since_idle_round_started_ ==
82 kMaxMarkCompactsInIdleRound) {
83 scavenges_since_last_idle_round_ = 0;
84 }
85 }
86 }
87
88 void NotifyScavenge() { ++scavenges_since_last_idle_round_; }
89
90 static size_t EstimateMarkingStepSize(size_t idle_time_in_ms,
91 size_t marking_speed_in_bytes_per_ms);
92
93 static int EstimateMarkSweepTime(intptr_t size_of_objects,
94 intptr_t mark_sweep_speed_in_bytes_per_ms);
95
31 private: 96 private:
97 void StartIdleRound() { mark_compacts_since_idle_round_started_ = 0; }
98 bool IsIdleRoundFinished() {
99 return mark_compacts_since_idle_round_started_ ==
100 kMaxMarkCompactsInIdleRound;
101 }
102 bool EnoughGarbageSinceLastIdleRound() {
103 return scavenges_since_last_idle_round_ >= kIdleScavengeThreshold;
104 }
105
106 static const int kMaxMarkCompactsInIdleRound = 7;
107 static const int kIdleScavengeThreshold = 5;
108 int mark_compacts_since_idle_round_started_;
109 int scavenges_since_last_idle_round_;
110
32 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); 111 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler);
33 }; 112 };
34 113
35 } // namespace internal 114 } // namespace internal
36 } // namespace v8 115 } // namespace v8
37 116
38 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ 117 #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') | src/heap/gc-idle-time-handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698