From 1ee2a998fa4c8842690467c96286a97b506f1424 Mon Sep 17 00:00:00 2001 From: mtrofin Date: Mon, 10 Apr 2017 08:15:40 -0700 Subject: [PATCH] Reland of Ensure counters are initialized, to avoid init on non-joinable threads. (patchset #1 id:1 of https://codereview.chromium.org/2812653002/ ) Reason for revert: Appears to be a flake. Both jgruber and I tried to repro locally and failed. Also change has little change of having had caused those failures. Original issue's description: > Revert of Ensure counters are initialized, to avoid init on non-joinable threads. (patchset #1 id:1 of https://codereview.chromium.org/2812543002/ ) > > Reason for revert: > https://build.chromium.org/p/client.v8/builders/V8%20Linux64%20-%20gyp/builds/5221 > > Original issue's description: > > Ensure counters are initialized, to avoid init on non-joinable threads. > > > > This occurs in the wasm scenario described in the referenced bug. > > DecodeWasmModule collects statistics. Blink inserts a CreateHistogramCallback that > > can't instantiate a histogram on non-joinable threads. Turns out, DecodeWasmModule > > is scheduled on such a thread, now that we have async compilation. > > > > This fix pre-initializes histograms when the callback is applied, which is assumed to > > be in a context that can carry out the instantiation. In Blink, this happens on the main > > thread. > > > > BUG=chromium:709684 > > > > Review-Url: https://codereview.chromium.org/2812543002 > > Cr-Commit-Position: refs/heads/master@{#44522} > > Committed: https://chromium.googlesource.com/v8/v8/+/022e7ddf232b0696eb595769fa702463c417db5e > > TBR=jochen@chromium.org,mtrofin@chromium.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=chromium:709684 > > Review-Url: https://codereview.chromium.org/2812653002 > Cr-Commit-Position: refs/heads/master@{#44527} > Committed: https://chromium.googlesource.com/v8/v8/+/038bafcb8c0435bc4130228237124331295d4713 TBR=jochen@chromium.org,jgruber@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=chromium:709684 Review-Url: https://codereview.chromium.org/2813673002 Cr-Commit-Position: refs/heads/master@{#44529} --- src/api.cc | 1 + src/counters.cc | 24 ++++++++++++++++++++++++ src/counters.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/src/api.cc b/src/api.cc index a0990efd76..be65add4b2 100644 --- a/src/api.cc +++ b/src/api.cc @@ -8584,6 +8584,7 @@ void Isolate::SetCreateHistogramFunction(CreateHistogramCallback callback) { isolate->stats_table()->SetCreateHistogramFunction(callback); isolate->InitializeLoggingAndCounters(); isolate->counters()->ResetHistograms(); + isolate->counters()->InitializeHistograms(); } diff --git a/src/counters.cc b/src/counters.cc index 0b71d439cf..d1a1a44c9f 100644 --- a/src/counters.cc +++ b/src/counters.cc @@ -252,6 +252,30 @@ void Counters::ResetHistograms() { #define HM(name, caption) name##_.Reset(); HISTOGRAM_LEGACY_MEMORY_LIST(HM) + HISTOGRAM_MEMORY_LIST(HM) +#undef HM +} + +void Counters::InitializeHistograms() { +#define HR(name, caption, min, max, num_buckets) name##_.Enabled(); + HISTOGRAM_RANGE_LIST(HR) +#undef HR + +#define HT(name, caption, max, res) name##_.Enabled(); + HISTOGRAM_TIMER_LIST(HT) +#undef HT + +#define AHT(name, caption) name##_.Enabled(); + AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) +#undef AHT + +#define HP(name, caption) name##_.Enabled(); + HISTOGRAM_PERCENTAGE_LIST(HP) +#undef HP + +#define HM(name, caption) name##_.Enabled(); + HISTOGRAM_LEGACY_MEMORY_LIST(HM) + HISTOGRAM_MEMORY_LIST(HM) #undef HM } diff --git a/src/counters.h b/src/counters.h index 2e8d320789..f6ad865e35 100644 --- a/src/counters.h +++ b/src/counters.h @@ -1273,6 +1273,8 @@ class Counters { void ResetCounters(); void ResetHistograms(); + void InitializeHistograms(); + RuntimeCallStats* runtime_call_stats() { return &runtime_call_stats_; } private: