Skip to content

Commit 0262bc1

Browse files
isheludkoCommit Bot
authored andcommitted
[zone-stats] Introduce v8.zone_stats tracing category
... in order to make it possible to collect zone memory usage stats from Chrome. Drive-by-cleanup: move TracingFlags definition to a separate file. Bug: v8:10572 Change-Id: I05fb65e207d573d5c18821067cfff4c37f2d77cd Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2226561 Reviewed-by: Peter Marshall <petermarshall@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Igor Sheludko <ishell@chromium.org> Cr-Commit-Position: refs/heads/master@{#68135}
1 parent ae489de commit 0262bc1

11 files changed

Lines changed: 86 additions & 35 deletions

File tree

BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,6 +2630,8 @@ v8_source_set("v8_base_without_compiler") {
26302630
"src/logging/log.cc",
26312631
"src/logging/log.h",
26322632
"src/logging/off-thread-logger.h",
2633+
"src/logging/tracing-flags.cc",
2634+
"src/logging/tracing-flags.h",
26332635
"src/numbers/bignum-dtoa.cc",
26342636
"src/numbers/bignum-dtoa.h",
26352637
"src/numbers/bignum.cc",

src/api/api.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
#include <utility> // For move
1212
#include <vector>
1313

14-
#include "src/api/api-inl.h"
15-
1614
#include "include/v8-fast-api-calls.h"
1715
#include "include/v8-profiler.h"
1816
#include "include/v8-util.h"
17+
#include "src/api/api-inl.h"
1918
#include "src/api/api-natives.h"
2019
#include "src/base/functional.h"
2120
#include "src/base/logging.h"
@@ -58,6 +57,7 @@
5857
#include "src/json/json-parser.h"
5958
#include "src/json/json-stringifier.h"
6059
#include "src/logging/counters.h"
60+
#include "src/logging/tracing-flags.h"
6161
#include "src/numbers/conversions-inl.h"
6262
#include "src/objects/api-callbacks.h"
6363
#include "src/objects/contexts.h"

src/flags/flag-definitions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,10 @@ DEFINE_BOOL(track_gc_object_stats, false,
965965
DEFINE_BOOL(trace_gc_object_stats, false,
966966
"trace object counts and memory usage")
967967
DEFINE_BOOL(trace_zone_stats, false, "trace zone memory usage")
968+
DEFINE_GENERIC_IMPLICATION(
969+
trace_zone_stats,
970+
TracingFlags::zone_stats.store(
971+
v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE))
968972
DEFINE_BOOL(track_retaining_path, false,
969973
"enable support for tracking retaining path")
970974
DEFINE_DEBUG_BOOL(trace_backing_store, false, "trace backing store events")

src/logging/counters-inl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define V8_LOGGING_COUNTERS_INL_H_
77

88
#include "src/logging/counters.h"
9+
#include "src/logging/tracing-flags.h"
910

1011
namespace v8 {
1112
namespace internal {

src/logging/counters.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
namespace v8 {
1818
namespace internal {
1919

20-
std::atomic_uint TracingFlags::runtime_stats{0};
21-
std::atomic_uint TracingFlags::gc{0};
22-
std::atomic_uint TracingFlags::gc_stats{0};
23-
std::atomic_uint TracingFlags::ic_stats{0};
24-
2520
StatsTable::StatsTable(Counters* counters)
2621
: lookup_function_(nullptr),
2722
create_histogram_function_(nullptr),

src/logging/counters.h

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "src/execution/isolate.h"
1717
#include "src/init/heap-symbols.h"
1818
#include "src/logging/counters-definitions.h"
19+
#include "src/logging/tracing-flags.h"
1920
#include "src/objects/objects.h"
2021
#include "src/runtime/runtime.h"
2122
#include "src/tracing/trace-event.h"
@@ -26,33 +27,6 @@
2627
namespace v8 {
2728
namespace internal {
2829

29-
// This struct contains a set of flags that can be modified from multiple
30-
// threads at runtime unlike the normal FLAG_-like flags which are not modified
31-
// after V8 instance is initialized.
32-
33-
struct TracingFlags {
34-
static V8_EXPORT_PRIVATE std::atomic_uint runtime_stats;
35-
static V8_EXPORT_PRIVATE std::atomic_uint gc;
36-
static V8_EXPORT_PRIVATE std::atomic_uint gc_stats;
37-
static V8_EXPORT_PRIVATE std::atomic_uint ic_stats;
38-
39-
static bool is_runtime_stats_enabled() {
40-
return runtime_stats.load(std::memory_order_relaxed) != 0;
41-
}
42-
43-
static bool is_gc_enabled() {
44-
return gc.load(std::memory_order_relaxed) != 0;
45-
}
46-
47-
static bool is_gc_stats_enabled() {
48-
return gc_stats.load(std::memory_order_relaxed) != 0;
49-
}
50-
51-
static bool is_ic_stats_enabled() {
52-
return ic_stats.load(std::memory_order_relaxed) != 0;
53-
}
54-
};
55-
5630
// StatsCounters is an interface for plugging into external
5731
// counters for monitoring. Counters can be looked up and
5832
// manipulated by name.

src/logging/log-utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Log {
3737
FLAG_log_suspect || FLAG_ll_prof || FLAG_perf_basic_prof ||
3838
FLAG_perf_prof || FLAG_log_source_code || FLAG_gdbjit ||
3939
FLAG_log_internal_timer_events || FLAG_prof_cpp || FLAG_trace_ic ||
40-
FLAG_log_function_events;
40+
FLAG_log_function_events || FLAG_trace_zone_stats;
4141
}
4242

4343
// Frees all resources acquired in Initialize and Open... functions.

src/logging/tracing-flags.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2020 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+
#include "src/logging/tracing-flags.h"
6+
7+
namespace v8 {
8+
namespace internal {
9+
10+
std::atomic_uint TracingFlags::runtime_stats{0};
11+
std::atomic_uint TracingFlags::gc{0};
12+
std::atomic_uint TracingFlags::gc_stats{0};
13+
std::atomic_uint TracingFlags::ic_stats{0};
14+
std::atomic_uint TracingFlags::zone_stats{0};
15+
16+
} // namespace internal
17+
} // namespace v8

src/logging/tracing-flags.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright 2020 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_LOGGING_TRACING_FLAGS_H_
6+
#define V8_LOGGING_TRACING_FLAGS_H_
7+
8+
#include <atomic>
9+
10+
#include "src/base/macros.h"
11+
12+
namespace v8 {
13+
namespace internal {
14+
15+
// This struct contains a set of flags that can be modified from multiple
16+
// threads at runtime unlike the normal FLAG_-like flags which are not modified
17+
// after V8 instance is initialized.
18+
19+
struct TracingFlags {
20+
static V8_EXPORT_PRIVATE std::atomic_uint runtime_stats;
21+
static V8_EXPORT_PRIVATE std::atomic_uint gc;
22+
static V8_EXPORT_PRIVATE std::atomic_uint gc_stats;
23+
static V8_EXPORT_PRIVATE std::atomic_uint ic_stats;
24+
static V8_EXPORT_PRIVATE std::atomic_uint zone_stats;
25+
26+
static bool is_runtime_stats_enabled() {
27+
return runtime_stats.load(std::memory_order_relaxed) != 0;
28+
}
29+
30+
static bool is_gc_enabled() {
31+
return gc.load(std::memory_order_relaxed) != 0;
32+
}
33+
34+
static bool is_gc_stats_enabled() {
35+
return gc_stats.load(std::memory_order_relaxed) != 0;
36+
}
37+
38+
static bool is_ic_stats_enabled() {
39+
return ic_stats.load(std::memory_order_relaxed) != 0;
40+
}
41+
42+
static bool is_zone_stats_enabled() {
43+
return zone_stats.load(std::memory_order_relaxed) != 0;
44+
}
45+
};
46+
47+
} // namespace internal
48+
} // namespace v8
49+
50+
#endif // V8_LOGGING_TRACING_FLAGS_H_

src/tracing/trace-categories.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ PERFETTO_DEFINE_CATEGORIES(
4747
perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats_sampling")),
4848
perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.turbofan")),
4949
perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.wasm")),
50+
perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.zone_stats")),
5051
perfetto::Category::Group("v8,devtools.timeline"),
5152
perfetto::Category::Group(TRACE_DISABLED_BY_DEFAULT("v8.turbofan") ","
5253
TRACE_DISABLED_BY_DEFAULT("v8.wasm")));

0 commit comments

Comments
 (0)