v8
9.0.257(node16.0.0)
V8 is Google's open source JavaScript engine
heap-statistics.h
Go to the documentation of this file.
1
// Copyright 2021 the V8 project authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#
ifndef
INCLUDE_CPPGC_HEAP_STATISTICS_H_
6
#
define
INCLUDE_CPPGC_HEAP_STATISTICS_H_
7
8
#
include
<
memory
>
9
#
include
<
string
>
10
#
include
<
vector
>
11
12
namespace
cppgc
{
13
14
/**
15
* `HeapStatistics` contains memory consumption and utilization statistics for a
16
* cppgc heap.
17
*/
18
struct
HeapStatistics
final
{
19
/**
20
* Specifies the detail level of the heap statistics. Brief statistics contain
21
* only the top-level allocated and used memory statistics for the entire
22
* heap. Detailed statistics also contain a break down per space and page, as
23
* well as freelist statistics and object type histograms. Note that used
24
* memory reported by brief statistics and detailed statistics might differ
25
* slightly.
26
*/
27
enum
DetailLevel
:
uint8_t
{
28
kBrief
,
29
kDetailed
,
30
};
31
32
/**
33
* Statistics of object types. For each type the statistics record its name,
34
* how many objects of that type were allocated, and the overall size used by
35
* these objects.
36
*/
37
struct
ObjectStatistics
{
38
/** Number of distinct types in the heap. */
39
size_t
num_types
= 0;
40
/** Name of each type in the heap. */
41
std::vector<std::string>
type_name
;
42
/** Number of allocated objects per each type. */
43
std::vector<size_t>
type_count
;
44
/** Overall size of allocated objects per each type. */
45
std::vector<size_t>
type_bytes
;
46
};
47
48
/**
49
* Page granularity statistics. For each page the statistics record the
50
* allocated memory size and overall used memory size for the page.
51
*/
52
struct
PageStatistics
{
53
/** Overall amount of memory allocated for the page. */
54
size_t
physical_size_bytes
= 0;
55
/** Amount of memory actually used on the page. */
56
size_t
used_size_bytes
= 0;
57
};
58
59
/**
60
* Stastistics of the freelist (used only in non-large object spaces). For
61
* each bucket in the freelist the statistics record the bucket size, the
62
* number of freelist entries in the bucket, and the overall allocated memory
63
* consumed by these freelist entries.
64
*/
65
struct
FreeListStatistics
{
66
/** bucket sizes in the freelist. */
67
std::vector<size_t>
bucket_size
;
68
/** number of freelist entries per bucket. */
69
std::vector<size_t>
free_count
;
70
/** memory size concumed by freelist entries per size. */
71
std::vector<size_t>
free_size
;
72
};
73
74
/**
75
* Space granularity statistics. For each space the statistics record the
76
* space name, the amount of allocated memory and overall used memory for the
77
* space. The statistics also contain statistics for each of the space's
78
* pages, its freelist and the objects allocated on the space.
79
*/
80
struct
SpaceStatistics
{
81
/** The space name */
82
std::string
name
;
83
/** Overall amount of memory allocated for the space. */
84
size_t
physical_size_bytes
= 0;
85
/** Amount of memory actually used on the space. */
86
size_t
used_size_bytes
= 0;
87
/** Statistics for each of the pages in the space. */
88
std::vector<
PageStatistics
>
page_stats
;
89
/** Statistics for the freelist of the space. */
90
FreeListStatistics
free_list_stats
;
91
/** Statistics for object allocated on the space. Filled only when
92
* NameProvider::HideInternalNames() is false. */
93
ObjectStatistics
object_stats
;
94
};
95
96
/** Overall amount of memory allocated for the heap. */
97
size_t
physical_size_bytes
= 0;
98
/** Amount of memory actually used on the heap. */
99
size_t
used_size_bytes
= 0;
100
/** Detail level of this HeapStatistics. */
101
DetailLevel
detail_level
;
102
103
/** Statistics for each of the spaces in the heap. Filled only when
104
* detail_level is kDetailed. */
105
std::vector<
SpaceStatistics
>
space_stats
;
106
};
107
108
}
// namespace cppgc
109
110
#
endif
// INCLUDE_CPPGC_HEAP_STATISTICS_H_
cppgc::HeapStatistics::kBrief
@ kBrief
Definition:
heap-statistics.h:28
cppgc::HeapStatistics::SpaceStatistics::free_list_stats
FreeListStatistics free_list_stats
Definition:
heap-statistics.h:90
cppgc::HeapStatistics::SpaceStatistics::page_stats
std::vector< PageStatistics > page_stats
Definition:
heap-statistics.h:88
cppgc::HeapStatistics::ObjectStatistics::num_types
size_t num_types
Definition:
heap-statistics.h:39
cppgc::HeapStatistics::ObjectStatistics::type_bytes
std::vector< size_t > type_bytes
Definition:
heap-statistics.h:45
cppgc::HeapStatistics::detail_level
DetailLevel detail_level
Definition:
heap-statistics.h:101
cppgc::HeapStatistics::FreeListStatistics::free_count
std::vector< size_t > free_count
Definition:
heap-statistics.h:69
cppgc::HeapStatistics::SpaceStatistics::used_size_bytes
size_t used_size_bytes
Definition:
heap-statistics.h:86
cppgc
Definition:
allocation.h:17
cppgc::HeapStatistics::space_stats
std::vector< SpaceStatistics > space_stats
Definition:
heap-statistics.h:105
cppgc::HeapStatistics::SpaceStatistics::object_stats
ObjectStatistics object_stats
Definition:
heap-statistics.h:93
cppgc::HeapStatistics::physical_size_bytes
size_t physical_size_bytes
Definition:
heap-statistics.h:97
cppgc::HeapStatistics::FreeListStatistics
Definition:
heap-statistics.h:65
cppgc::HeapStatistics::SpaceStatistics
Definition:
heap-statistics.h:80
cppgc::HeapStatistics::ObjectStatistics::type_name
std::vector< std::string > type_name
Definition:
heap-statistics.h:41
cppgc::HeapStatistics::SpaceStatistics::physical_size_bytes
size_t physical_size_bytes
Definition:
heap-statistics.h:84
cppgc::HeapStatistics::ObjectStatistics::type_count
std::vector< size_t > type_count
Definition:
heap-statistics.h:43
cppgc::HeapStatistics::FreeListStatistics::free_size
std::vector< size_t > free_size
Definition:
heap-statistics.h:71
cppgc::HeapStatistics::kDetailed
@ kDetailed
Definition:
heap-statistics.h:29
cppgc::HeapStatistics::PageStatistics
Definition:
heap-statistics.h:52
cppgc::HeapStatistics::ObjectStatistics
Definition:
heap-statistics.h:37
cppgc::HeapStatistics::used_size_bytes
size_t used_size_bytes
Definition:
heap-statistics.h:99
cppgc::HeapStatistics::DetailLevel
DetailLevel
Definition:
heap-statistics.h:27
cppgc::HeapStatistics::SpaceStatistics::name
std::string name
Definition:
heap-statistics.h:82
cppgc::HeapStatistics::PageStatistics::physical_size_bytes
size_t physical_size_bytes
Definition:
heap-statistics.h:54
cppgc::HeapStatistics::FreeListStatistics::bucket_size
std::vector< size_t > bucket_size
Definition:
heap-statistics.h:67
cppgc::HeapStatistics::PageStatistics::used_size_bytes
size_t used_size_bytes
Definition:
heap-statistics.h:56
include
cppgc
heap-statistics.h
Generated on Tue Apr 20 2021 15:07:22 for v8 by
1.8.17