1// Copyright 2019 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 V8_COUNTERS_DEFINITIONS_H_
6#define V8_COUNTERS_DEFINITIONS_H_
7
8namespace v8 {
9namespace internal {
10
11#define HISTOGRAM_RANGE_LIST(HR) \
12 /* Generic range histograms: HR(name, caption, min, max, num_buckets) */ \
13 HR(background_marking, V8.GCBackgroundMarking, 0, 10000, 101) \
14 HR(background_scavenger, V8.GCBackgroundScavenger, 0, 10000, 101) \
15 HR(background_sweeping, V8.GCBackgroundSweeping, 0, 10000, 101) \
16 HR(detached_context_age_in_gc, V8.DetachedContextAgeInGC, 0, 20, 21) \
17 HR(code_cache_reject_reason, V8.CodeCacheRejectReason, 1, 6, 6) \
18 HR(errors_thrown_per_context, V8.ErrorsThrownPerContext, 0, 200, 20) \
19 HR(debug_feature_usage, V8.DebugFeatureUsage, 1, 7, 7) \
20 HR(incremental_marking_reason, V8.GCIncrementalMarkingReason, 0, 21, 22) \
21 HR(incremental_marking_sum, V8.GCIncrementalMarkingSum, 0, 10000, 101) \
22 HR(mark_compact_reason, V8.GCMarkCompactReason, 0, 21, 22) \
23 HR(gc_finalize_clear, V8.GCFinalizeMC.Clear, 0, 10000, 101) \
24 HR(gc_finalize_epilogue, V8.GCFinalizeMC.Epilogue, 0, 10000, 101) \
25 HR(gc_finalize_evacuate, V8.GCFinalizeMC.Evacuate, 0, 10000, 101) \
26 HR(gc_finalize_finish, V8.GCFinalizeMC.Finish, 0, 10000, 101) \
27 HR(gc_finalize_mark, V8.GCFinalizeMC.Mark, 0, 10000, 101) \
28 HR(gc_finalize_prologue, V8.GCFinalizeMC.Prologue, 0, 10000, 101) \
29 HR(gc_finalize_sweep, V8.GCFinalizeMC.Sweep, 0, 10000, 101) \
30 HR(gc_scavenger_scavenge_main, V8.GCScavenger.ScavengeMain, 0, 10000, 101) \
31 HR(gc_scavenger_scavenge_roots, V8.GCScavenger.ScavengeRoots, 0, 10000, 101) \
32 HR(gc_mark_compactor, V8.GCMarkCompactor, 0, 10000, 101) \
33 HR(gc_marking_sum, V8.GCMarkingSum, 0, 10000, 101) \
34 /* Range and bucket matches BlinkGC.MainThreadMarkingThroughput. */ \
35 HR(gc_main_thread_marking_throughput, V8.GCMainThreadMarkingThroughput, 0, \
36 100000, 50) \
37 HR(scavenge_reason, V8.GCScavengeReason, 0, 21, 22) \
38 HR(young_generation_handling, V8.GCYoungGenerationHandling, 0, 2, 3) \
39 /* Asm/Wasm. */ \
40 HR(wasm_functions_per_asm_module, V8.WasmFunctionsPerModule.asm, 1, 1000000, \
41 51) \
42 HR(wasm_functions_per_wasm_module, V8.WasmFunctionsPerModule.wasm, 1, \
43 1000000, 51) \
44 HR(array_buffer_big_allocations, V8.ArrayBufferLargeAllocations, 0, 4096, \
45 13) \
46 HR(array_buffer_new_size_failures, V8.ArrayBufferNewSizeFailures, 0, 4096, \
47 13) \
48 HR(shared_array_allocations, V8.SharedArrayAllocationSizes, 0, 4096, 13) \
49 HR(wasm_asm_function_size_bytes, V8.WasmFunctionSizeBytes.asm, 1, GB, 51) \
50 HR(wasm_wasm_function_size_bytes, V8.WasmFunctionSizeBytes.wasm, 1, GB, 51) \
51 HR(wasm_asm_module_size_bytes, V8.WasmModuleSizeBytes.asm, 1, GB, 51) \
52 HR(wasm_wasm_module_size_bytes, V8.WasmModuleSizeBytes.wasm, 1, GB, 51) \
53 HR(wasm_asm_min_mem_pages_count, V8.WasmMinMemPagesCount.asm, 1, 2 << 16, \
54 51) \
55 HR(wasm_wasm_min_mem_pages_count, V8.WasmMinMemPagesCount.wasm, 1, 2 << 16, \
56 51) \
57 HR(wasm_wasm_max_mem_pages_count, V8.WasmMaxMemPagesCount.wasm, 1, 2 << 16, \
58 51) \
59 HR(wasm_decode_asm_module_peak_memory_bytes, \
60 V8.WasmDecodeModulePeakMemoryBytes.asm, 1, GB, 51) \
61 HR(wasm_decode_wasm_module_peak_memory_bytes, \
62 V8.WasmDecodeModulePeakMemoryBytes.wasm, 1, GB, 51) \
63 HR(asm_wasm_translation_peak_memory_bytes, \
64 V8.AsmWasmTranslationPeakMemoryBytes, 1, GB, 51) \
65 HR(wasm_compile_function_peak_memory_bytes, \
66 V8.WasmCompileFunctionPeakMemoryBytes, 1, GB, 51) \
67 HR(asm_module_size_bytes, V8.AsmModuleSizeBytes, 1, GB, 51) \
68 HR(asm_wasm_translation_throughput, V8.AsmWasmTranslationThroughput, 1, 100, \
69 20) \
70 HR(wasm_lazy_compilation_throughput, V8.WasmLazyCompilationThroughput, 1, \
71 10000, 50) \
72 HR(compile_script_cache_behaviour, V8.CompileScript.CacheBehaviour, 0, 20, \
73 21) \
74 HR(wasm_memory_allocation_result, V8.WasmMemoryAllocationResult, 0, 3, 4) \
75 HR(wasm_address_space_usage_mb, V8.WasmAddressSpaceUsageMiB, 0, 1 << 20, \
76 128) \
77 /* code size of live modules, collected on GC */ \
78 HR(wasm_module_code_size_mb, V8.WasmModuleCodeSizeMiB, 0, 1024, 64) \
79 /* code size of modules after baseline compilation */ \
80 HR(wasm_module_code_size_mb_after_baseline, \
81 V8.WasmModuleCodeSizeBaselineMiB, 0, 1024, 64) \
82 /* code size of modules after top-tier compilation */ \
83 HR(wasm_module_code_size_mb_after_top_tier, V8.WasmModuleCodeSizeTopTierMiB, \
84 0, 1024, 64)
85
86#define HISTOGRAM_TIMER_LIST(HT) \
87 /* Timer histograms, not thread safe: HT(name, caption, max, unit) */ \
88 /* Garbage collection timers. */ \
89 HT(gc_context, V8.GCContext, 10000, \
90 MILLISECOND) /* GC context cleanup time */ \
91 HT(gc_idle_notification, V8.GCIdleNotification, 10000, MILLISECOND) \
92 HT(gc_incremental_marking, V8.GCIncrementalMarking, 10000, MILLISECOND) \
93 HT(gc_incremental_marking_start, V8.GCIncrementalMarkingStart, 10000, \
94 MILLISECOND) \
95 HT(gc_incremental_marking_finalize, V8.GCIncrementalMarkingFinalize, 10000, \
96 MILLISECOND) \
97 HT(gc_low_memory_notification, V8.GCLowMemoryNotification, 10000, \
98 MILLISECOND) \
99 /* Compilation times. */ \
100 HT(collect_source_positions, V8.CollectSourcePositions, 1000000, \
101 MICROSECOND) \
102 HT(compile, V8.CompileMicroSeconds, 1000000, MICROSECOND) \
103 HT(compile_eval, V8.CompileEvalMicroSeconds, 1000000, MICROSECOND) \
104 /* Serialization as part of compilation (code caching) */ \
105 HT(compile_serialize, V8.CompileSerializeMicroSeconds, 100000, MICROSECOND) \
106 HT(compile_deserialize, V8.CompileDeserializeMicroSeconds, 1000000, \
107 MICROSECOND) \
108 /* Total compilation time incl. caching/parsing */ \
109 HT(compile_script, V8.CompileScriptMicroSeconds, 1000000, MICROSECOND) \
110 /* Total JavaScript execution time (including callbacks and runtime calls */ \
111 HT(execute, V8.Execute, 1000000, MICROSECOND) \
112 /* Asm/Wasm */ \
113 HT(asm_wasm_translation_time, V8.AsmWasmTranslationMicroSeconds, 1000000, \
114 MICROSECOND) \
115 HT(wasm_lazy_compilation_time, V8.WasmLazyCompilationMicroSeconds, 1000000, \
116 MICROSECOND)
117
118#define TIMED_HISTOGRAM_LIST(HT) \
119 /* Timer histograms, thread safe: HT(name, caption, max, unit) */ \
120 /* Garbage collection timers. */ \
121 HT(gc_compactor, V8.GCCompactor, 10000, MILLISECOND) \
122 HT(gc_compactor_background, V8.GCCompactorBackground, 10000, MILLISECOND) \
123 HT(gc_compactor_foreground, V8.GCCompactorForeground, 10000, MILLISECOND) \
124 HT(gc_finalize, V8.GCFinalizeMC, 10000, MILLISECOND) \
125 HT(gc_finalize_background, V8.GCFinalizeMCBackground, 10000, MILLISECOND) \
126 HT(gc_finalize_foreground, V8.GCFinalizeMCForeground, 10000, MILLISECOND) \
127 HT(gc_finalize_reduce_memory, V8.GCFinalizeMCReduceMemory, 10000, \
128 MILLISECOND) \
129 HT(gc_finalize_reduce_memory_background, \
130 V8.GCFinalizeMCReduceMemoryBackground, 10000, MILLISECOND) \
131 HT(gc_finalize_reduce_memory_foreground, \
132 V8.GCFinalizeMCReduceMemoryForeground, 10000, MILLISECOND) \
133 HT(gc_scavenger, V8.GCScavenger, 10000, MILLISECOND) \
134 HT(gc_scavenger_background, V8.GCScavengerBackground, 10000, MILLISECOND) \
135 HT(gc_scavenger_foreground, V8.GCScavengerForeground, 10000, MILLISECOND) \
136 /* TurboFan timers. */ \
137 HT(turbofan_optimize_prepare, V8.TurboFanOptimizePrepare, 1000000, \
138 MICROSECOND) \
139 HT(turbofan_optimize_execute, V8.TurboFanOptimizeExecute, 1000000, \
140 MICROSECOND) \
141 HT(turbofan_optimize_finalize, V8.TurboFanOptimizeFinalize, 1000000, \
142 MICROSECOND) \
143 HT(turbofan_optimize_total_foreground, V8.TurboFanOptimizeTotalForeground, \
144 10000000, MICROSECOND) \
145 HT(turbofan_optimize_total_background, V8.TurboFanOptimizeTotalBackground, \
146 10000000, MICROSECOND) \
147 HT(turbofan_optimize_total_time, V8.TurboFanOptimizeTotalTime, 10000000, \
148 MICROSECOND) \
149 HT(turbofan_osr_prepare, V8.TurboFanOptimizeForOnStackReplacementPrepare, \
150 1000000, MICROSECOND) \
151 HT(turbofan_osr_execute, V8.TurboFanOptimizeForOnStackReplacementExecute, \
152 1000000, MICROSECOND) \
153 HT(turbofan_osr_finalize, V8.TurboFanOptimizeForOnStackReplacementFinalize, \
154 1000000, MICROSECOND) \
155 HT(turbofan_osr_total_time, \
156 V8.TurboFanOptimizeForOnStackReplacementTotalTime, 10000000, MICROSECOND) \
157 /* Wasm timers. */ \
158 HT(wasm_decode_asm_module_time, V8.WasmDecodeModuleMicroSeconds.asm, \
159 1000000, MICROSECOND) \
160 HT(wasm_decode_wasm_module_time, V8.WasmDecodeModuleMicroSeconds.wasm, \
161 1000000, MICROSECOND) \
162 HT(wasm_decode_asm_function_time, V8.WasmDecodeFunctionMicroSeconds.asm, \
163 1000000, MICROSECOND) \
164 HT(wasm_decode_wasm_function_time, V8.WasmDecodeFunctionMicroSeconds.wasm, \
165 1000000, MICROSECOND) \
166 HT(wasm_compile_asm_module_time, V8.WasmCompileModuleMicroSeconds.asm, \
167 10000000, MICROSECOND) \
168 HT(wasm_compile_wasm_module_time, V8.WasmCompileModuleMicroSeconds.wasm, \
169 10000000, MICROSECOND) \
170 HT(wasm_compile_asm_function_time, V8.WasmCompileFunctionMicroSeconds.asm, \
171 1000000, MICROSECOND) \
172 HT(wasm_compile_wasm_function_time, V8.WasmCompileFunctionMicroSeconds.wasm, \
173 1000000, MICROSECOND) \
174 HT(liftoff_compile_time, V8.LiftoffCompileMicroSeconds, 10000000, \
175 MICROSECOND) \
176 HT(wasm_instantiate_wasm_module_time, \
177 V8.WasmInstantiateModuleMicroSeconds.wasm, 10000000, MICROSECOND) \
178 HT(wasm_instantiate_asm_module_time, \
179 V8.WasmInstantiateModuleMicroSeconds.asm, 10000000, MICROSECOND) \
180 /* Total compilation time incl. caching/parsing for various cache states. */ \
181 HT(compile_script_with_produce_cache, \
182 V8.CompileScriptMicroSeconds.ProduceCache, 1000000, MICROSECOND) \
183 HT(compile_script_with_isolate_cache_hit, \
184 V8.CompileScriptMicroSeconds.IsolateCacheHit, 1000000, MICROSECOND) \
185 HT(compile_script_with_consume_cache, \
186 V8.CompileScriptMicroSeconds.ConsumeCache, 1000000, MICROSECOND) \
187 HT(compile_script_consume_failed, \
188 V8.CompileScriptMicroSeconds.ConsumeCache.Failed, 1000000, MICROSECOND) \
189 HT(compile_script_no_cache_other, \
190 V8.CompileScriptMicroSeconds.NoCache.Other, 1000000, MICROSECOND) \
191 HT(compile_script_no_cache_because_inline_script, \
192 V8.CompileScriptMicroSeconds.NoCache.InlineScript, 1000000, MICROSECOND) \
193 HT(compile_script_no_cache_because_script_too_small, \
194 V8.CompileScriptMicroSeconds.NoCache.ScriptTooSmall, 1000000, \
195 MICROSECOND) \
196 HT(compile_script_no_cache_because_cache_too_cold, \
197 V8.CompileScriptMicroSeconds.NoCache.CacheTooCold, 1000000, MICROSECOND) \
198 HT(compile_script_on_background, \
199 V8.CompileScriptMicroSeconds.BackgroundThread, 1000000, MICROSECOND) \
200 HT(compile_function_on_background, \
201 V8.CompileFunctionMicroSeconds.BackgroundThread, 1000000, MICROSECOND)
202
203#define AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) \
204 AHT(compile_lazy, V8.CompileLazyMicroSeconds)
205
206#define HISTOGRAM_PERCENTAGE_LIST(HP) \
207 /* Heap fragmentation. */ \
208 HP(external_fragmentation_total, V8.MemoryExternalFragmentationTotal) \
209 HP(external_fragmentation_old_space, V8.MemoryExternalFragmentationOldSpace) \
210 HP(external_fragmentation_code_space, \
211 V8.MemoryExternalFragmentationCodeSpace) \
212 HP(external_fragmentation_map_space, V8.MemoryExternalFragmentationMapSpace) \
213 HP(external_fragmentation_lo_space, V8.MemoryExternalFragmentationLoSpace)
214
215// Note: These use Histogram with options (min=1000, max=500000, buckets=50).
216#define HISTOGRAM_LEGACY_MEMORY_LIST(HM) \
217 HM(heap_sample_total_committed, V8.MemoryHeapSampleTotalCommitted) \
218 HM(heap_sample_total_used, V8.MemoryHeapSampleTotalUsed) \
219 HM(heap_sample_map_space_committed, V8.MemoryHeapSampleMapSpaceCommitted) \
220 HM(heap_sample_code_space_committed, V8.MemoryHeapSampleCodeSpaceCommitted) \
221 HM(heap_sample_maximum_committed, V8.MemoryHeapSampleMaximumCommitted)
222
223// WARNING: STATS_COUNTER_LIST_* is a very large macro that is causing MSVC
224// Intellisense to crash. It was broken into two macros (each of length 40
225// lines) rather than one macro (of length about 80 lines) to work around
226// this problem. Please avoid using recursive macros of this length when
227// possible.
228#define STATS_COUNTER_LIST_1(SC) \
229 /* Global Handle Count*/ \
230 SC(global_handles, V8.GlobalHandles) \
231 /* OS Memory allocated */ \
232 SC(memory_allocated, V8.OsMemoryAllocated) \
233 SC(maps_normalized, V8.MapsNormalized) \
234 SC(maps_created, V8.MapsCreated) \
235 SC(elements_transitions, V8.ObjectElementsTransitions) \
236 SC(props_to_dictionary, V8.ObjectPropertiesToDictionary) \
237 SC(elements_to_dictionary, V8.ObjectElementsToDictionary) \
238 SC(alive_after_last_gc, V8.AliveAfterLastGC) \
239 SC(objs_since_last_young, V8.ObjsSinceLastYoung) \
240 SC(objs_since_last_full, V8.ObjsSinceLastFull) \
241 SC(string_table_capacity, V8.StringTableCapacity) \
242 SC(number_of_symbols, V8.NumberOfSymbols) \
243 SC(inlined_copied_elements, V8.InlinedCopiedElements) \
244 SC(compilation_cache_hits, V8.CompilationCacheHits) \
245 SC(compilation_cache_misses, V8.CompilationCacheMisses) \
246 /* Amount of evaled source code. */ \
247 SC(total_eval_size, V8.TotalEvalSize) \
248 /* Amount of loaded source code. */ \
249 SC(total_load_size, V8.TotalLoadSize) \
250 /* Amount of parsed source code. */ \
251 SC(total_parse_size, V8.TotalParseSize) \
252 /* Amount of source code skipped over using preparsing. */ \
253 SC(total_preparse_skipped, V8.TotalPreparseSkipped) \
254 /* Amount of compiled source code. */ \
255 SC(total_compile_size, V8.TotalCompileSize) \
256 /* Number of contexts created from scratch. */ \
257 SC(contexts_created_from_scratch, V8.ContextsCreatedFromScratch) \
258 /* Number of contexts created by partial snapshot. */ \
259 SC(contexts_created_by_snapshot, V8.ContextsCreatedBySnapshot) \
260 /* Number of code objects found from pc. */ \
261 SC(pc_to_code, V8.PcToCode) \
262 SC(pc_to_code_cached, V8.PcToCodeCached) \
263 /* The store-buffer implementation of the write barrier. */ \
264 SC(store_buffer_overflows, V8.StoreBufferOverflows)
265
266#define STATS_COUNTER_LIST_2(SC) \
267 /* Amount of (JS) compiled code. */ \
268 SC(total_compiled_code_size, V8.TotalCompiledCodeSize) \
269 SC(gc_compactor_caused_by_request, V8.GCCompactorCausedByRequest) \
270 SC(gc_compactor_caused_by_promoted_data, V8.GCCompactorCausedByPromotedData) \
271 SC(gc_compactor_caused_by_oldspace_exhaustion, \
272 V8.GCCompactorCausedByOldspaceExhaustion) \
273 SC(gc_last_resort_from_js, V8.GCLastResortFromJS) \
274 SC(gc_last_resort_from_handles, V8.GCLastResortFromHandles) \
275 SC(cow_arrays_converted, V8.COWArraysConverted) \
276 SC(constructed_objects_runtime, V8.ConstructedObjectsRuntime) \
277 SC(megamorphic_stub_cache_updates, V8.MegamorphicStubCacheUpdates) \
278 SC(enum_cache_hits, V8.EnumCacheHits) \
279 SC(enum_cache_misses, V8.EnumCacheMisses) \
280 SC(string_add_runtime, V8.StringAddRuntime) \
281 SC(sub_string_runtime, V8.SubStringRuntime) \
282 SC(regexp_entry_runtime, V8.RegExpEntryRuntime) \
283 SC(stack_interrupts, V8.StackInterrupts) \
284 SC(runtime_profiler_ticks, V8.RuntimeProfilerTicks) \
285 SC(soft_deopts_executed, V8.SoftDeoptsExecuted) \
286 SC(new_space_bytes_available, V8.MemoryNewSpaceBytesAvailable) \
287 SC(new_space_bytes_committed, V8.MemoryNewSpaceBytesCommitted) \
288 SC(new_space_bytes_used, V8.MemoryNewSpaceBytesUsed) \
289 SC(old_space_bytes_available, V8.MemoryOldSpaceBytesAvailable) \
290 SC(old_space_bytes_committed, V8.MemoryOldSpaceBytesCommitted) \
291 SC(old_space_bytes_used, V8.MemoryOldSpaceBytesUsed) \
292 SC(code_space_bytes_available, V8.MemoryCodeSpaceBytesAvailable) \
293 SC(code_space_bytes_committed, V8.MemoryCodeSpaceBytesCommitted) \
294 SC(code_space_bytes_used, V8.MemoryCodeSpaceBytesUsed) \
295 SC(map_space_bytes_available, V8.MemoryMapSpaceBytesAvailable) \
296 SC(map_space_bytes_committed, V8.MemoryMapSpaceBytesCommitted) \
297 SC(map_space_bytes_used, V8.MemoryMapSpaceBytesUsed) \
298 SC(lo_space_bytes_available, V8.MemoryLoSpaceBytesAvailable) \
299 SC(lo_space_bytes_committed, V8.MemoryLoSpaceBytesCommitted) \
300 SC(lo_space_bytes_used, V8.MemoryLoSpaceBytesUsed) \
301 /* Total code size (including metadata) of baseline code or bytecode. */ \
302 SC(total_baseline_code_size, V8.TotalBaselineCodeSize) \
303 /* Total count of functions compiled using the baseline compiler. */ \
304 SC(total_baseline_compile_count, V8.TotalBaselineCompileCount)
305
306#define STATS_COUNTER_TS_LIST(SC) \
307 SC(wasm_generated_code_size, V8.WasmGeneratedCodeBytes) \
308 SC(wasm_reloc_size, V8.WasmRelocBytes) \
309 SC(wasm_lazily_compiled_functions, V8.WasmLazilyCompiledFunctions) \
310 SC(liftoff_compiled_functions, V8.LiftoffCompiledFunctions) \
311 SC(liftoff_unsupported_functions, V8.LiftoffUnsupportedFunctions)
312
313// List of counters that can be incremented from generated code. We need them in
314// a separate list to be able to relocate them.
315#define STATS_COUNTER_NATIVE_CODE_LIST(SC) \
316 /* Number of write barriers executed at runtime. */ \
317 SC(write_barriers, V8.WriteBarriers) \
318 SC(constructed_objects, V8.ConstructedObjects) \
319 SC(fast_new_closure_total, V8.FastNewClosureTotal) \
320 SC(regexp_entry_native, V8.RegExpEntryNative) \
321 SC(string_add_native, V8.StringAddNative) \
322 SC(sub_string_native, V8.SubStringNative) \
323 SC(ic_keyed_load_generic_smi, V8.ICKeyedLoadGenericSmi) \
324 SC(ic_keyed_load_generic_symbol, V8.ICKeyedLoadGenericSymbol) \
325 SC(ic_keyed_load_generic_slow, V8.ICKeyedLoadGenericSlow) \
326 SC(megamorphic_stub_cache_probes, V8.MegamorphicStubCacheProbes) \
327 SC(megamorphic_stub_cache_misses, V8.MegamorphicStubCacheMisses)
328
329} // namespace internal
330} // namespace v8
331
332#endif // V8_COUNTERS_DEFINITIONS_H_
333