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

Side by Side Diff: runtime/vm/class_table.cc

Issue 487973002: Track per-class promotion stats. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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 | « runtime/vm/class_table.h ('k') | runtime/vm/heap.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #include "vm/class_table.h" 5 #include "vm/class_table.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 #include "vm/freelist.h" 7 #include "vm/freelist.h"
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/raw_object.h" 10 #include "vm/raw_object.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 186 }
187 } 187 }
188 188
189 189
190 void ClassHeapStats::Initialize() { 190 void ClassHeapStats::Initialize() {
191 pre_gc.Reset(); 191 pre_gc.Reset();
192 post_gc.Reset(); 192 post_gc.Reset();
193 recent.Reset(); 193 recent.Reset();
194 accumulated.Reset(); 194 accumulated.Reset();
195 last_reset.Reset(); 195 last_reset.Reset();
196 promoted_count = 0;
197 promoted_size = 0;
196 } 198 }
197 199
198 200
199 void ClassHeapStats::ResetAtNewGC() { 201 void ClassHeapStats::ResetAtNewGC() {
200 pre_gc.new_count = post_gc.new_count + recent.new_count; 202 pre_gc.new_count = post_gc.new_count + recent.new_count;
201 pre_gc.new_size = post_gc.new_size + recent.new_size; 203 pre_gc.new_size = post_gc.new_size + recent.new_size;
202 // Accumulate allocations. 204 // Accumulate allocations.
203 accumulated.new_count += recent.new_count - last_reset.new_count; 205 accumulated.new_count += recent.new_count - last_reset.new_count;
204 accumulated.new_size += recent.new_size - last_reset.new_size; 206 accumulated.new_size += recent.new_size - last_reset.new_size;
205 last_reset.ResetNew(); 207 last_reset.ResetNew();
206 post_gc.ResetNew(); 208 post_gc.ResetNew();
207 recent.ResetNew(); 209 recent.ResetNew();
210 old_pre_new_gc_count_ = recent.old_count;
211 old_pre_new_gc_size_ = recent.old_size;
208 } 212 }
209 213
210 214
211 void ClassHeapStats::ResetAtOldGC() { 215 void ClassHeapStats::ResetAtOldGC() {
212 pre_gc.old_count = post_gc.old_count + recent.old_count; 216 pre_gc.old_count = post_gc.old_count + recent.old_count;
213 pre_gc.old_size = post_gc.old_size + recent.old_size; 217 pre_gc.old_size = post_gc.old_size + recent.old_size;
214 // Accumulate allocations. 218 // Accumulate allocations.
215 accumulated.old_count += recent.old_count - last_reset.old_count; 219 accumulated.old_count += recent.old_count - last_reset.old_count;
216 accumulated.old_size += recent.old_size - last_reset.old_size; 220 accumulated.old_size += recent.old_size - last_reset.old_size;
217 last_reset.ResetOld(); 221 last_reset.ResetOld();
218 post_gc.ResetOld(); 222 post_gc.ResetOld();
219 recent.ResetOld(); 223 recent.ResetOld();
220 } 224 }
221 225
222 226
223 void ClassHeapStats::UpdateSize(intptr_t instance_size) { 227 void ClassHeapStats::UpdateSize(intptr_t instance_size) {
224 pre_gc.UpdateSize(instance_size); 228 pre_gc.UpdateSize(instance_size);
225 post_gc.UpdateSize(instance_size); 229 post_gc.UpdateSize(instance_size);
226 recent.UpdateSize(instance_size); 230 recent.UpdateSize(instance_size);
227 accumulated.UpdateSize(instance_size); 231 accumulated.UpdateSize(instance_size);
228 last_reset.UpdateSize(instance_size); 232 last_reset.UpdateSize(instance_size);
233 promoted_size = promoted_count * instance_size;
234 old_pre_new_gc_size_ = old_pre_new_gc_count_ * instance_size;
229 } 235 }
230 236
231 237
232 void ClassHeapStats::ResetAccumulator() { 238 void ClassHeapStats::ResetAccumulator() {
233 // Remember how much was allocated so we can subtract this from the result 239 // Remember how much was allocated so we can subtract this from the result
234 // when printing. 240 // when printing.
235 last_reset.new_count = recent.new_count; 241 last_reset.new_count = recent.new_count;
236 last_reset.new_size = recent.new_size; 242 last_reset.new_size = recent.new_size;
237 last_reset.old_count = recent.old_count; 243 last_reset.old_count = recent.old_count;
238 last_reset.old_size = recent.old_size; 244 last_reset.old_size = recent.old_size;
239 accumulated.Reset(); 245 accumulated.Reset();
240 } 246 }
241 247
242 248
249 void ClassHeapStats::UpdatePromotedAfterNewGC() {
250 promoted_count = recent.old_count - old_pre_new_gc_count_;
251 promoted_size = recent.old_size - old_pre_new_gc_size_;
252 }
253
254
243 void ClassHeapStats::PrintToJSONObject(const Class& cls, 255 void ClassHeapStats::PrintToJSONObject(const Class& cls,
244 JSONObject* obj) const { 256 JSONObject* obj) const {
245 obj->AddProperty("type", "ClassHeapStats"); 257 obj->AddProperty("type", "ClassHeapStats");
246 obj->AddPropertyF("id", "allocationprofile/%" Pd "", cls.id()); 258 obj->AddPropertyF("id", "allocationprofile/%" Pd "", cls.id());
247 obj->AddProperty("class", cls); 259 obj->AddProperty("class", cls);
248 { 260 {
249 JSONArray new_stats(obj, "new"); 261 JSONArray new_stats(obj, "new");
250 new_stats.AddValue(pre_gc.new_count); 262 new_stats.AddValue(pre_gc.new_count);
251 new_stats.AddValue(pre_gc.new_size); 263 new_stats.AddValue(pre_gc.new_size);
252 new_stats.AddValue(post_gc.new_count); 264 new_stats.AddValue(post_gc.new_count);
(...skipping 11 matching lines...) Expand all
264 old_stats.AddValue(pre_gc.old_size); 276 old_stats.AddValue(pre_gc.old_size);
265 old_stats.AddValue(post_gc.old_count); 277 old_stats.AddValue(post_gc.old_count);
266 old_stats.AddValue(post_gc.old_size); 278 old_stats.AddValue(post_gc.old_size);
267 old_stats.AddValue(recent.old_count); 279 old_stats.AddValue(recent.old_count);
268 old_stats.AddValue(recent.old_size); 280 old_stats.AddValue(recent.old_size);
269 old_stats.AddValue64(accumulated.old_count + recent.old_count - 281 old_stats.AddValue64(accumulated.old_count + recent.old_count -
270 last_reset.old_count); 282 last_reset.old_count);
271 old_stats.AddValue64(accumulated.old_size + recent.old_size - 283 old_stats.AddValue64(accumulated.old_size + recent.old_size -
272 last_reset.old_size); 284 last_reset.old_size);
273 } 285 }
286 obj->AddProperty("promotedInstances", promoted_count);
287 obj->AddProperty("promotedBytes", promoted_size);
274 } 288 }
275 289
276 290
277 void ClassTable::UpdateAllocatedNew(intptr_t cid, intptr_t size) { 291 void ClassTable::UpdateAllocatedNew(intptr_t cid, intptr_t size) {
278 ClassHeapStats* stats = PreliminaryStatsAt(cid); 292 ClassHeapStats* stats = PreliminaryStatsAt(cid);
279 ASSERT(stats != NULL); 293 ASSERT(stats != NULL);
280 ASSERT(size != 0); 294 ASSERT(size != 0);
281 stats->recent.AddNew(size); 295 stats->recent.AddNew(size);
282 } 296 }
283 297
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 void ClassTable::ResetCountersNew() { 349 void ClassTable::ResetCountersNew() {
336 for (intptr_t i = 0; i < kNumPredefinedCids; i++) { 350 for (intptr_t i = 0; i < kNumPredefinedCids; i++) {
337 predefined_class_heap_stats_table_[i].ResetAtNewGC(); 351 predefined_class_heap_stats_table_[i].ResetAtNewGC();
338 } 352 }
339 for (intptr_t i = kNumPredefinedCids; i < top_; i++) { 353 for (intptr_t i = kNumPredefinedCids; i < top_; i++) {
340 class_heap_stats_table_[i].ResetAtNewGC(); 354 class_heap_stats_table_[i].ResetAtNewGC();
341 } 355 }
342 } 356 }
343 357
344 358
359 void ClassTable::UpdatePromoted() {
360 for (intptr_t i = 0; i < kNumPredefinedCids; i++) {
361 predefined_class_heap_stats_table_[i].UpdatePromotedAfterNewGC();
362 }
363 for (intptr_t i = kNumPredefinedCids; i < top_; i++) {
364 class_heap_stats_table_[i].UpdatePromotedAfterNewGC();
365 }
366 }
367
368
345 void ClassTable::AllocationProfilePrintJSON(JSONStream* stream) { 369 void ClassTable::AllocationProfilePrintJSON(JSONStream* stream) {
346 Isolate* isolate = Isolate::Current(); 370 Isolate* isolate = Isolate::Current();
347 ASSERT(isolate != NULL); 371 ASSERT(isolate != NULL);
348 Heap* heap = isolate->heap(); 372 Heap* heap = isolate->heap();
349 ASSERT(heap != NULL); 373 ASSERT(heap != NULL);
350 JSONObject obj(stream); 374 JSONObject obj(stream);
351 obj.AddProperty("type", "AllocationProfile"); 375 obj.AddProperty("type", "AllocationProfile");
352 obj.AddProperty("id", "allocationprofile"); 376 obj.AddProperty("id", "allocationprofile");
353 obj.AddPropertyF( 377 obj.AddPropertyF(
354 "dateLastAccumulatorReset", 378 "dateLastAccumulatorReset",
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 427
404 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { 428 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) {
405 ClassHeapStats* stats = PreliminaryStatsAt(cid); 429 ClassHeapStats* stats = PreliminaryStatsAt(cid);
406 ASSERT(stats != NULL); 430 ASSERT(stats != NULL);
407 ASSERT(size >= 0); 431 ASSERT(size >= 0);
408 stats->post_gc.AddNew(size); 432 stats->post_gc.AddNew(size);
409 } 433 }
410 434
411 435
412 } // namespace dart 436 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_table.h ('k') | runtime/vm/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698