 Chromium Code Reviews
 Chromium Code Reviews Issue 2379823004:
  [Tracing] Integrate GC object statistics with tracing.  (Closed)
    
  
    Issue 2379823004:
  [Tracing] Integrate GC object statistics with tracing.  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include "src/heap/object-stats.h" | 5 #include "src/heap/object-stats.h" | 
| 6 | 6 | 
| 7 #include "src/compilation-cache.h" | 7 #include "src/compilation-cache.h" | 
| 8 #include "src/counters.h" | 8 #include "src/counters.h" | 
| 9 #include "src/heap/heap-inl.h" | 9 #include "src/heap/heap-inl.h" | 
| 10 #include "src/isolate.h" | 10 #include "src/isolate.h" | 
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 // 100KB larger. | 35 // 100KB larger. | 
| 36 V8_NOINLINE static void PrintJSONArray(size_t* array, const int len) { | 36 V8_NOINLINE static void PrintJSONArray(size_t* array, const int len) { | 
| 37 PrintF("[ "); | 37 PrintF("[ "); | 
| 38 for (int i = 0; i < len; i++) { | 38 for (int i = 0; i < len; i++) { | 
| 39 PrintF("%zu", array[i]); | 39 PrintF("%zu", array[i]); | 
| 40 if (i != (len - 1)) PrintF(", "); | 40 if (i != (len - 1)) PrintF(", "); | 
| 41 } | 41 } | 
| 42 PrintF(" ]"); | 42 PrintF(" ]"); | 
| 43 } | 43 } | 
| 44 | 44 | 
| 45 V8_NOINLINE static void DumpJSONArray(std::stringstream& stream, size_t* array, | |
| 
fmeawad
2016/09/30 00:44:05
I think you should merge the print and dump functi
 
Michael Lippautz
2016/09/30 09:09:44
Please merge the printing and dumping where possib
 
lpy
2016/09/30 18:21:58
I am not sure if we should, PrintF will end up cal
 | |
| 46 const int len) { | |
| 47 stream << "["; | |
| 48 for (int i = 0; i < len; i++) { | |
| 49 stream << array[i]; | |
| 50 if (i != (len - 1)) stream << ","; | |
| 51 } | |
| 52 stream << "]"; | |
| 53 } | |
| 54 | |
| 45 void ObjectStats::PrintJSON(const char* key) { | 55 void ObjectStats::PrintJSON(const char* key) { | 
| 46 double time = isolate()->time_millis_since_init(); | 56 double time = isolate()->time_millis_since_init(); | 
| 47 int gc_count = heap()->gc_count(); | 57 int gc_count = heap()->gc_count(); | 
| 48 | 58 | 
| 49 #define PRINT_KEY_AND_ID() \ | 59 #define PRINT_KEY_AND_ID() \ | 
| 50 PrintF("\"isolate\": \"%p\", \"id\": %d, \"key\": \"%s\", ", \ | 60 PrintF("\"isolate\": \"%p\", \"id\": %d, \"key\": \"%s\", ", \ | 
| 51 reinterpret_cast<void*>(isolate()), gc_count, key); | 61 reinterpret_cast<void*>(isolate()), gc_count, key); | 
| 52 | 62 | 
| 53 // gc_descriptor | 63 // gc_descriptor | 
| 54 PrintF("{ "); | 64 PrintF("{ "); | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 INSTANCE_TYPE_LIST(INSTANCE_TYPE_WRAPPER) | 105 INSTANCE_TYPE_LIST(INSTANCE_TYPE_WRAPPER) | 
| 96 CODE_KIND_LIST(CODE_KIND_WRAPPER) | 106 CODE_KIND_LIST(CODE_KIND_WRAPPER) | 
| 97 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER) | 107 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER) | 
| 98 CODE_AGE_LIST_COMPLETE(CODE_AGE_WRAPPER) | 108 CODE_AGE_LIST_COMPLETE(CODE_AGE_WRAPPER) | 
| 99 | 109 | 
| 100 #undef INSTANCE_TYPE_WRAPPER | 110 #undef INSTANCE_TYPE_WRAPPER | 
| 101 #undef CODE_KIND_WRAPPER | 111 #undef CODE_KIND_WRAPPER | 
| 102 #undef FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER | 112 #undef FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER | 
| 103 #undef CODE_AGE_WRAPPER | 113 #undef CODE_AGE_WRAPPER | 
| 104 #undef PRINT_INSTANCE_TYPE_DATA | 114 #undef PRINT_INSTANCE_TYPE_DATA | 
| 115 #undef PRINT_KEY_AND_ID | |
| 116 } | |
| 117 | |
| 118 void ObjectStats::Dump(std::stringstream& stream) { | |
| 119 double time = isolate()->time_millis_since_init(); | |
| 120 int gc_count = heap()->gc_count(); | |
| 121 | |
| 122 stream << "{"; | |
| 123 stream << "\"isolate\":\"" << reinterpret_cast<void*>(isolate()) << "\","; | |
| 124 stream << "\"id\":" << gc_count << ","; | |
| 125 stream << "\"time\":" << time << ","; | |
| 126 stream << "\"bucket_sizes\":["; | |
| 127 for (int i = 0; i < kNumberOfBuckets; i++) { | |
| 128 stream << (1 << (kFirstBucketShift + i)); | |
| 129 if (i != (kNumberOfBuckets - 1)) stream << ","; | |
| 130 } | |
| 131 stream << "],"; | |
| 132 stream << "\"type_data\":{"; | |
| 133 | |
| 134 #define PRINT_INSTANCE_TYPE_DATA(name, index) \ | |
| 135 stream << "\"" << name << "\":{"; \ | |
| 136 stream << "\"type\":" << static_cast<int>(index) << ","; \ | |
| 137 stream << "\"overall\":" << object_sizes_[index] << ","; \ | |
| 138 stream << "\"count\":" << object_counts_[index] << ","; \ | |
| 139 stream << "\"over_allocated\":" << over_allocated_[index] << ","; \ | |
| 140 stream << "\"histogram\":"; \ | |
| 141 DumpJSONArray(stream, size_histogram_[index], kNumberOfBuckets); \ | |
| 142 stream << ",\"over_allocated_histogram\":"; \ | |
| 143 DumpJSONArray(stream, over_allocated_histogram_[index], kNumberOfBuckets); \ | |
| 144 stream << "},"; | |
| 145 | |
| 146 #define INSTANCE_TYPE_WRAPPER(name) PRINT_INSTANCE_TYPE_DATA(#name, name) | |
| 147 #define CODE_KIND_WRAPPER(name) \ | |
| 148 PRINT_INSTANCE_TYPE_DATA("*CODE_" #name, \ | |
| 149 FIRST_CODE_KIND_SUB_TYPE + Code::name) | |
| 150 #define FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER(name) \ | |
| 151 PRINT_INSTANCE_TYPE_DATA("*FIXED_ARRAY_" #name, \ | |
| 152 FIRST_FIXED_ARRAY_SUB_TYPE + name) | |
| 153 #define CODE_AGE_WRAPPER(name) \ | |
| 154 PRINT_INSTANCE_TYPE_DATA( \ | |
| 155 "*CODE_AGE_" #name, \ | |
| 156 FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge - Code::kFirstCodeAge) | |
| 157 | |
| 158 INSTANCE_TYPE_LIST(INSTANCE_TYPE_WRAPPER); | |
| 159 CODE_KIND_LIST(CODE_KIND_WRAPPER); | |
| 160 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER); | |
| 161 CODE_AGE_LIST_COMPLETE(CODE_AGE_WRAPPER); | |
| 162 stream << "\"END\":{}}}"; | |
| 163 | |
| 164 #undef INSTANCE_TYPE_WRAPPER | |
| 165 #undef CODE_KIND_WRAPPER | |
| 166 #undef FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER | |
| 167 #undef CODE_AGE_WRAPPER | |
| 168 #undef PRINT_INSTANCE_TYPE_DATA | |
| 105 } | 169 } | 
| 106 | 170 | 
| 107 void ObjectStats::CheckpointObjectStats() { | 171 void ObjectStats::CheckpointObjectStats() { | 
| 108 base::LockGuard<base::Mutex> lock_guard(object_stats_mutex.Pointer()); | 172 base::LockGuard<base::Mutex> lock_guard(object_stats_mutex.Pointer()); | 
| 109 Counters* counters = isolate()->counters(); | 173 Counters* counters = isolate()->counters(); | 
| 110 #define ADJUST_LAST_TIME_OBJECT_COUNT(name) \ | 174 #define ADJUST_LAST_TIME_OBJECT_COUNT(name) \ | 
| 111 counters->count_of_##name()->Increment( \ | 175 counters->count_of_##name()->Increment( \ | 
| 112 static_cast<int>(object_counts_[name])); \ | 176 static_cast<int>(object_counts_[name])); \ | 
| 113 counters->count_of_##name()->Decrement( \ | 177 counters->count_of_##name()->Decrement( \ | 
| 114 static_cast<int>(object_counts_last_time_[name])); \ | 178 static_cast<int>(object_counts_last_time_[name])); \ | 
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 SLOW_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE); | 595 SLOW_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE); | 
| 532 FixedArray* fast_cache = native_ctx->fast_template_instantiations_cache(); | 596 FixedArray* fast_cache = native_ctx->fast_template_instantiations_cache(); | 
| 533 stats_->RecordFixedArraySubTypeStats( | 597 stats_->RecordFixedArraySubTypeStats( | 
| 534 fast_cache, FAST_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE, | 598 fast_cache, FAST_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE, | 
| 535 fast_cache->Size(), 0); | 599 fast_cache->Size(), 0); | 
| 536 } | 600 } | 
| 537 } | 601 } | 
| 538 | 602 | 
| 539 } // namespace internal | 603 } // namespace internal | 
| 540 } // namespace v8 | 604 } // namespace v8 | 
| OLD | NEW |