Commit fd3d44f6 authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[counters] Add --slow-histograms flag

The V8.Execute histogram is not free and can cause more overhead
than expected. This CL is guarding slower histograms behind a new
--slow-histograms flag.

For now --slow-histograms is enabled by default. Once all
chrome-side changes and benchmark changes have landed it will be
disabled by default.

--dump-counters will automatically enable --slow-histograms.

The goal is to not report slow histograms on UMA by default on stable:
- 100% reporting on canary/dev/beta
- 1% reporting on stable or specific finch experiments

Chrome-side feature: https://crrev.com/c/3065464

Bug: v8:11946
Change-Id: I23c782288e10ceb76323d72eceea9170739fd543
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3067318
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76041}
parent caf6582a
......@@ -1784,6 +1784,9 @@ DEFINE_BOOL_READONLY(minor_mc, false,
DEFINE_BOOL(help, false, "Print usage message, including flags, on console")
DEFINE_BOOL(dump_counters, false, "Dump counters on exit")
DEFINE_BOOL(slow_histograms, true, "Enable slow histograms with more overhead.")
DEFINE_IMPLICATION(dump_counters, slow_histograms)
DEFINE_BOOL(dump_counters_nvp, false,
"Dump counters as name-value pairs on exit")
DEFINE_BOOL(use_external_strings, false, "Use external strings for source code")
......
......@@ -124,12 +124,14 @@ namespace internal {
MICROSECOND) \
/* Total compilation time incl. caching/parsing */ \
HT(compile_script, V8.CompileScriptMicroSeconds, 1000000, MICROSECOND) \
/* Total JavaScript execution time (including callbacks and runtime calls */ \
HT(execute, V8.Execute, 1000000, MICROSECOND) \
/* Time for lazily compiling Wasm functions. */ \
HT(wasm_lazy_compile_time, V8.WasmLazyCompileTimeMicroSeconds, 100000000, \
MICROSECOND)
#define HISTOGRAM_TIMER_LIST_SLOW(HT) \
/* Total JavaScript execution time (including callbacks and runtime calls */ \
HT(execute, V8.Execute, 1000000, MICROSECOND)
#define TIMED_HISTOGRAM_LIST(HT) \
/* Timer histograms, thread safe: HT(name, caption, max, unit) */ \
/* Garbage collection timers. */ \
......
......@@ -156,7 +156,7 @@ Counters::Counters(Isolate* isolate)
} kHistogramTimers[] = {
#define HT(name, caption, max, res) \
{&Counters::name##_, #caption, max, HistogramTimerResolution::res},
HISTOGRAM_TIMER_LIST(HT)
HISTOGRAM_TIMER_LIST(HT) HISTOGRAM_TIMER_LIST_SLOW(HT)
#undef HT
};
for (const auto& timer : kHistogramTimers) {
......@@ -300,6 +300,10 @@ void Counters::ResetCreateHistogramFunction(CreateHistogramCallback f) {
HISTOGRAM_TIMER_LIST(HT)
#undef HT
#define HT(name, caption, max, res) name##_.Reset(FLAG_slow_histograms);
HISTOGRAM_TIMER_LIST_SLOW(HT)
#undef HT
#define HT(name, caption, max, res) name##_.Reset();
TIMED_HISTOGRAM_LIST(HT)
#undef HT
......
......@@ -242,7 +242,9 @@ class Histogram {
Counters* counters() const { return counters_; }
// Reset the cached internal pointer.
void Reset() { histogram_ = CreateHistogram(); }
void Reset(bool create_new = true) {
histogram_ = create_new ? CreateHistogram() : nullptr;
}
private:
friend class Counters;
......@@ -674,6 +676,7 @@ class Counters : public std::enable_shared_from_this<Counters> {
#define HT(name, caption, max, res) \
HistogramTimer* name() { return &name##_; }
HISTOGRAM_TIMER_LIST(HT)
HISTOGRAM_TIMER_LIST_SLOW(HT)
#undef HT
#define HT(name, caption, max, res) \
......@@ -712,6 +715,7 @@ class Counters : public std::enable_shared_from_this<Counters> {
enum Id {
#define RATE_ID(name, caption, max, res) k_##name,
HISTOGRAM_TIMER_LIST(RATE_ID)
HISTOGRAM_TIMER_LIST_SLOW(RATE_ID)
TIMED_HISTOGRAM_LIST(RATE_ID)
#undef RATE_ID
#define AGGREGATABLE_ID(name, caption) k_##name,
......@@ -784,6 +788,7 @@ class Counters : public std::enable_shared_from_this<Counters> {
#define HT(name, caption, max, res) HistogramTimer name##_;
HISTOGRAM_TIMER_LIST(HT)
HISTOGRAM_TIMER_LIST_SLOW(HT)
#undef HT
#define HT(name, caption, max, res) TimedHistogram name##_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment