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

Unified Diff: runtime/vm/class_table.cc

Issue 173013004: Add accumulator to allocation profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/class_table.cc
diff --git a/runtime/vm/class_table.cc b/runtime/vm/class_table.cc
index 46965376694d6e082f643353603da735d1f7394d..336a42f566e0cf65028a6a8c01deecb20fd07e97 100644
--- a/runtime/vm/class_table.cc
+++ b/runtime/vm/class_table.cc
@@ -145,6 +145,14 @@ void ClassHeapStats::Initialize() {
allocated_since_gc_old_space = 0;
allocated_size_since_gc_new_space = 0;
allocated_size_since_gc_old_space = 0;
+ accumulated_post_gc_new_space = 0;
+ accumulated_post_gc_old_space = 0;
+ accumulated_post_gc_size_new_space = 0;
+ accumulated_post_gc_size_old_space = 0;
+ accumulator_new_space_offset = 0;
+ accumulator_old_space_offset = 0;
+ accumulator_size_new_space_offset = 0;
+ accumulator_size_old_space_offset = 0;
}
@@ -153,6 +161,13 @@ void ClassHeapStats::ResetAtNewGC() {
allocated_since_gc_new_space;
allocated_size_before_gc_new_space = live_size_after_gc_new_space +
allocated_size_since_gc_new_space;
+ // Accumulate allocations.
+ accumulated_post_gc_new_space +=
+ allocated_since_gc_new_space - accumulator_new_space_offset;
+ accumulated_post_gc_size_new_space +=
+ allocated_size_since_gc_new_space - accumulator_size_new_space_offset;
+ accumulator_new_space_offset = 0;
+ accumulator_size_new_space_offset = 0;
live_after_gc_new_space = 0;
live_size_after_gc_new_space = 0;
allocated_since_gc_new_space = 0;
@@ -165,6 +180,13 @@ void ClassHeapStats::ResetAtOldGC() {
allocated_since_gc_old_space;
allocated_size_before_gc_old_space = live_size_after_gc_old_space +
allocated_size_since_gc_old_space;
+ // Accumulate allocations.
+ accumulated_post_gc_old_space +=
+ allocated_since_gc_old_space - accumulator_old_space_offset;
+ accumulated_post_gc_size_old_space +=
+ allocated_size_since_gc_old_space - accumulator_size_old_space_offset;
+ accumulator_old_space_offset = 0;
+ accumulator_size_old_space_offset = 0;
live_after_gc_old_space = 0;
live_size_after_gc_old_space = 0;
allocated_since_gc_old_space = 0;
@@ -191,6 +213,20 @@ void ClassHeapStats::UpdateSize(intptr_t instance_size) {
}
+void ClassHeapStats::ResetAccumulator() {
+ // Remember how much was allocated so we can subtract this from the result
+ // when printing.
+ accumulator_new_space_offset = allocated_since_gc_new_space;
+ accumulator_old_space_offset = allocated_since_gc_old_space;
+ accumulator_size_new_space_offset = allocated_size_since_gc_new_space;
+ accumulator_size_old_space_offset = allocated_size_since_gc_old_space;
+ accumulated_post_gc_new_space = 0;
+ accumulated_post_gc_old_space = 0;
+ accumulated_post_gc_size_new_space = 0;
+ accumulated_post_gc_size_old_space = 0;
+}
+
+
void ClassHeapStats::PrintTOJSONArray(const Class& cls, JSONArray* array) {
JSONObject obj(array);
obj.AddProperty("type", "ClassHeapStats");
@@ -203,6 +239,12 @@ void ClassHeapStats::PrintTOJSONArray(const Class& cls, JSONArray* array) {
new_stats.AddValue(live_size_after_gc_new_space);
new_stats.AddValue(allocated_since_gc_new_space);
new_stats.AddValue(allocated_size_since_gc_new_space);
+ new_stats.AddValue64(accumulated_post_gc_new_space +
+ allocated_since_gc_new_space -
+ accumulator_new_space_offset);
+ new_stats.AddValue64(accumulated_post_gc_size_new_space +
+ allocated_size_since_gc_new_space -
+ accumulator_size_new_space_offset);
}
{
JSONArray old_stats(&obj, "old");
@@ -212,6 +254,12 @@ void ClassHeapStats::PrintTOJSONArray(const Class& cls, JSONArray* array) {
old_stats.AddValue(live_size_after_gc_old_space);
old_stats.AddValue(allocated_since_gc_old_space);
old_stats.AddValue(allocated_size_since_gc_old_space);
+ old_stats.AddValue64(accumulated_post_gc_old_space +
+ allocated_since_gc_old_space -
+ accumulator_old_space_offset);
+ old_stats.AddValue64(accumulated_post_gc_size_old_space +
+ allocated_size_since_gc_old_space -
+ accumulator_size_old_space_offset);
}
}
@@ -322,6 +370,43 @@ void ClassTable::AllocationProfilePrintToJSONStream(JSONStream* stream) {
}
+void ClassTable::ResetAllocationAccumulators() {
+ Class& cls = Class::Handle();
+ for (intptr_t i = 1; i < kNumPredefinedCids; i++) {
+ if (!HasValidClassAt(i) || (i == kFreeListElement) || (i == kSmiCid)) {
+ continue;
+ }
+ cls = At(i);
+ if (!(cls.is_finalized() || cls.is_prefinalized())) {
+ // Not finalized.
+ continue;
+ }
+ // Update size before resetting accumulator.
+ if (ShouldUpdateSizeForClassId(i)) {
+ intptr_t instance_size = cls.instance_size();
+ predefined_class_heap_stats_table_[i].UpdateSize(instance_size);
+ }
+ predefined_class_heap_stats_table_[i].ResetAccumulator();
+ }
+ for (intptr_t i = kNumPredefinedCids; i < top_; i++) {
+ if (!HasValidClassAt(i)) {
+ continue;
+ }
+ cls = At(i);
+ if (!(cls.is_finalized() || cls.is_prefinalized())) {
+ // Not finalized.
+ continue;
+ }
+ // Update size before resetting accumulator.
+ if (ShouldUpdateSizeForClassId(i)) {
+ intptr_t instance_size = cls.instance_size();
+ class_heap_stats_table_[i].UpdateSize(instance_size);
+ }
+ class_heap_stats_table_[i].ResetAccumulator();
+ }
+}
+
+
void ClassTable::UpdateLiveOld(intptr_t cid, intptr_t size) {
ClassHeapStats* stats = StatsAt(cid);
ASSERT(stats != NULL);

Powered by Google App Engine
This is Rietveld 408576698