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

Unified Diff: src/heap/object-stats.h

Issue 2129173002: [heap] Rework and improve object stats tracing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation on Windows Created 4 years, 5 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
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/object-stats.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/object-stats.h
diff --git a/src/heap/object-stats.h b/src/heap/object-stats.h
index ce0a317cf1bf83ac8190efa5288f1229ae3770f6..2448141da126d490a14112f54d34499ccbc9dfcb 100644
--- a/src/heap/object-stats.h
+++ b/src/heap/object-stats.h
@@ -14,7 +14,7 @@ namespace internal {
class ObjectStats {
public:
- explicit ObjectStats(Heap* heap) : heap_(heap) {}
+ explicit ObjectStats(Heap* heap) : heap_(heap) { ClearObjectStats(); }
// ObjectStats are kept in two arrays, counts and sizes. Related stats are
// stored in a contiguous linear buffer. Stats groups are stored one after
@@ -30,14 +30,14 @@ class ObjectStats {
void ClearObjectStats(bool clear_last_time_stats = false);
- void TraceObjectStats();
- void TraceObjectStat(const char* name, int count, int size, double time);
void CheckpointObjectStats();
+ void PrintJSON(const char* key);
void RecordObjectStats(InstanceType type, size_t size) {
DCHECK(type <= LAST_TYPE);
object_counts_[type]++;
object_sizes_[type] += size;
+ size_histogram_[type][HistogramIndexFromSize(size)]++;
}
void RecordCodeSubTypeStats(int code_sub_type, int code_age, size_t size) {
@@ -52,12 +52,22 @@ class ObjectStats {
object_sizes_[code_sub_type_index] += size;
object_counts_[code_age_index]++;
object_sizes_[code_age_index] += size;
+ const int idx = HistogramIndexFromSize(size);
+ size_histogram_[code_sub_type_index][idx]++;
+ size_histogram_[code_age_index][idx]++;
}
- void RecordFixedArraySubTypeStats(int array_sub_type, size_t size) {
+ void RecordFixedArraySubTypeStats(int array_sub_type, size_t size,
+ size_t over_allocated) {
DCHECK(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE);
object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++;
object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size;
+ size_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]
+ [HistogramIndexFromSize(size)]++;
+ over_allocated_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] +=
+ over_allocated;
+ over_allocated_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]
+ [HistogramIndexFromSize(over_allocated)]++;
}
size_t object_count_last_gc(size_t index) {
@@ -72,46 +82,49 @@ class ObjectStats {
Heap* heap() { return heap_; }
private:
- Heap* heap_;
+ static const int kFirstBucketShift = 5; // <=32
+ static const int kLastBucketShift = 19; // >512k
+ static const int kFirstBucket = 1 << kFirstBucketShift;
+ static const int kLastBucket = 1 << kLastBucketShift;
+ static const int kNumberOfBuckets = kLastBucketShift - kFirstBucketShift;
+
+ int HistogramIndexFromSize(size_t size) {
+ if (size == 0) return 0;
+ int idx =
+ static_cast<int>(log2(static_cast<double>(size))) - kFirstBucketShift;
+ return idx < 0 ? 0 : idx;
+ }
- // Object counts and used memory by InstanceType
+ Heap* heap_;
+ // Object counts and used memory by InstanceType.
size_t object_counts_[OBJECT_STATS_COUNT];
size_t object_counts_last_time_[OBJECT_STATS_COUNT];
size_t object_sizes_[OBJECT_STATS_COUNT];
size_t object_sizes_last_time_[OBJECT_STATS_COUNT];
+ // Approximation of overallocated memory by InstanceType.
+ size_t over_allocated_[OBJECT_STATS_COUNT];
+ // Detailed histograms by InstanceType.
+ size_t size_histogram_[OBJECT_STATS_COUNT][kNumberOfBuckets];
+ size_t over_allocated_histogram_[OBJECT_STATS_COUNT][kNumberOfBuckets];
};
class ObjectStatsCollector {
public:
- static void CollectStatistics(StaticVisitorBase::VisitorId id, Map* map,
- HeapObject* obj);
- static void CollectFixedArrayStatistics(HeapObject* obj);
-
- static void CountFixedArray(FixedArrayBase* fixed_array,
- FixedArraySubInstanceType fast_type,
- FixedArraySubInstanceType dictionary_type);
- static void RecordMapStats(Map* map, HeapObject* obj);
- static void RecordCodeStats(Map* map, HeapObject* obj);
- static void RecordSharedFunctionInfoStats(Map* map, HeapObject* obj);
- static void RecordFixedArrayStats(Map* map, HeapObject* obj);
-};
-
-class MarkCompactObjectStatsVisitor
- : public StaticMarkingVisitor<MarkCompactObjectStatsVisitor> {
- public:
- static void Initialize(VisitorDispatchTable<Callback>* original);
+ static void CollectStatistics(ObjectStats* stats, HeapObject* obj);
- template <VisitorId id>
- static inline void Visit(Map* map, HeapObject* obj);
-};
-
-class IncrementalMarkingObjectStatsVisitor
- : public StaticMarkingVisitor<IncrementalMarkingObjectStatsVisitor> {
- public:
- static void Initialize(VisitorDispatchTable<Callback>* original);
-
- template <VisitorId id>
- static inline void Visit(Map* map, HeapObject* obj);
+ private:
+ static void RecordMapDetails(ObjectStats* stats, Heap* heap, HeapObject* obj);
+ static void RecordCodeDetails(ObjectStats* stats, Heap* heap,
+ HeapObject* obj);
+ static void RecordSharedFunctionInfoDetails(ObjectStats* stats, Heap* heap,
+ HeapObject* obj);
+ static void RecordFixedArrayDetails(ObjectStats* stats, Heap* heap,
+ HeapObject* obj);
+
+ static void RecordJSObjectDetails(ObjectStats* stats, Heap* heap,
+ JSObject* object);
+ static void RecordJSWeakCollectionDetails(ObjectStats* stats, Heap* heap,
+ JSWeakCollection* obj);
};
} // namespace internal
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/object-stats.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698