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

Side by Side Diff: runtime/vm/pages.h

Issue 235343004: Accelerate old-space growth (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 | runtime/vm/pages.cc » ('j') | runtime/vm/pages.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_PAGES_H_ 5 #ifndef VM_PAGES_H_
6 #define VM_PAGES_H_ 6 #define VM_PAGES_H_
7 7
8 #include "vm/freelist.h" 8 #include "vm/freelist.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/spaces.h" 10 #include "vm/spaces.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // runs. 88 // runs.
89 class PageSpaceGarbageCollectionHistory { 89 class PageSpaceGarbageCollectionHistory {
90 public: 90 public:
91 PageSpaceGarbageCollectionHistory(); 91 PageSpaceGarbageCollectionHistory();
92 ~PageSpaceGarbageCollectionHistory() {} 92 ~PageSpaceGarbageCollectionHistory() {}
93 93
94 void AddGarbageCollectionTime(int64_t start, int64_t end); 94 void AddGarbageCollectionTime(int64_t start, int64_t end);
95 95
96 int GarbageCollectionTimeFraction(); 96 int GarbageCollectionTimeFraction();
97 97
98 bool IsEmpty() const { return index_ == 0; }
99
98 private: 100 private:
99 static const intptr_t kHistoryLength = 4; 101 static const intptr_t kHistoryLength = 4;
100 int64_t start_[kHistoryLength]; 102 int64_t start_[kHistoryLength];
101 int64_t end_[kHistoryLength]; 103 int64_t end_[kHistoryLength];
102 intptr_t index_; 104 intptr_t index_;
103 105
104 DISALLOW_ALLOCATION(); 106 DISALLOW_ALLOCATION();
105 DISALLOW_COPY_AND_ASSIGN(PageSpaceGarbageCollectionHistory); 107 DISALLOW_COPY_AND_ASSIGN(PageSpaceGarbageCollectionHistory);
106 }; 108 };
107 109
108 110
109 // If GC is able to reclaim more than heap_growth_ratio (in percent) memory
110 // and if the relative GC time is below a given threshold,
111 // then the heap is not grown when the next GC decision is made.
112 // PageSpaceController controls the heap size. 111 // PageSpaceController controls the heap size.
113 class PageSpaceController { 112 class PageSpaceController {
114 public: 113 public:
115 PageSpaceController(int heap_growth_ratio, 114 PageSpaceController(int heap_growth_ratio,
116 int heap_growth_rate, 115 int heap_growth_max,
117 int garbage_collection_time_ratio); 116 int garbage_collection_time_ratio);
118 ~PageSpaceController(); 117 ~PageSpaceController();
119 118
120 // Returns whether growing to 'after' should trigger a GC. 119 // Returns whether growing to 'after' should trigger a GC.
121 // This method can be called before allocation (e.g., pretenuring) or after 120 // This method can be called before allocation (e.g., pretenuring) or after
122 // (e.g., promotion), as it does not change the state of the controller. 121 // (e.g., promotion), as it does not change the state of the controller.
123 bool NeedsGarbageCollection(SpaceUsage after) const; 122 bool NeedsGarbageCollection(SpaceUsage after) const;
124 123
125 // Should be called after each collection to update the controller state. 124 // Should be called after each collection to update the controller state.
126 // A garbage collection is considered as successful if more than
127 // heap_growth_ratio % of memory got deallocated by the garbage collector.
128 // In this case garbage collection will be performed next time. Otherwise
129 // the heap will grow.
130 void EvaluateGarbageCollection(SpaceUsage before, 125 void EvaluateGarbageCollection(SpaceUsage before,
131 SpaceUsage after, 126 SpaceUsage after,
132 int64_t start, int64_t end); 127 int64_t start, int64_t end);
133 128
134 int64_t last_code_collection_in_us() { return last_code_collection_in_us_; } 129 int64_t last_code_collection_in_us() { return last_code_collection_in_us_; }
135 void set_last_code_collection_in_us(int64_t t) { 130 void set_last_code_collection_in_us(int64_t t) {
136 last_code_collection_in_us_ = t; 131 last_code_collection_in_us_ = t;
137 } 132 }
138 133
139 void Enable(SpaceUsage current) { 134 void Enable(SpaceUsage current) {
(...skipping 17 matching lines...) Expand all
157 intptr_t grow_heap_; 152 intptr_t grow_heap_;
158 153
159 // If the garbage collector was not able to free more than heap_growth_ratio_ 154 // If the garbage collector was not able to free more than heap_growth_ratio_
160 // memory, then the heap is grown. Otherwise garbage collection is performed. 155 // memory, then the heap is grown. Otherwise garbage collection is performed.
161 int heap_growth_ratio_; 156 int heap_growth_ratio_;
162 157
163 // The desired percent of heap in-use after a garbage collection. 158 // The desired percent of heap in-use after a garbage collection.
164 // Equivalent to \frac{100-heap_growth_ratio_}{100}. 159 // Equivalent to \frac{100-heap_growth_ratio_}{100}.
165 double desired_utilization_; 160 double desired_utilization_;
166 161
167 // Number of pages we grow. 162 // Max number of pages we grow.
168 int heap_growth_rate_; 163 int heap_growth_max_;
169 164
170 // If the relative GC time stays below garbage_collection_time_ratio_ 165 // If the relative GC time goes above garbage_collection_time_ratio_ %,
171 // garbage collection can be performed. 166 // we grow the heap more aggressively.
172 int garbage_collection_time_ratio_; 167 int garbage_collection_time_ratio_;
173 168
174 // The time in microseconds of the last time we tried to collect unused 169 // The time in microseconds of the last time we tried to collect unused
175 // code. 170 // code.
176 int64_t last_code_collection_in_us_; 171 int64_t last_code_collection_in_us_;
177 172
178 PageSpaceGarbageCollectionHistory history_; 173 PageSpaceGarbageCollectionHistory history_;
179 174
180 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpaceController); 175 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpaceController);
181 }; 176 };
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 intptr_t collections_; 317 intptr_t collections_;
323 318
324 friend class PageSpaceController; 319 friend class PageSpaceController;
325 320
326 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); 321 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace);
327 }; 322 };
328 323
329 } // namespace dart 324 } // namespace dart
330 325
331 #endif // VM_PAGES_H_ 326 #endif // VM_PAGES_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/pages.cc » ('j') | runtime/vm/pages.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698