Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/counters.cc

Issue 2929853003: Fix use of history timers in background threads. (Closed)
Patch Set: Merge with master. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/counters.h" 5 #include "src/counters.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 8
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/builtins/builtins-definitions.h" 10 #include "src/builtins/builtins-definitions.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 void Histogram::AddSample(int sample) { 70 void Histogram::AddSample(int sample) {
71 if (Enabled()) { 71 if (Enabled()) {
72 counters_->AddHistogramSample(histogram_, sample); 72 counters_->AddHistogramSample(histogram_, sample);
73 } 73 }
74 } 74 }
75 75
76 void* Histogram::CreateHistogram() const { 76 void* Histogram::CreateHistogram() const {
77 return counters_->CreateHistogram(name_, min_, max_, num_buckets_); 77 return counters_->CreateHistogram(name_, min_, max_, num_buckets_);
78 } 78 }
79 79
80 80 void TimedHistogram::Start(base::ElapsedTimer* timer, Isolate* isolate) {
81 // Start the timer. 81 if (Enabled()) timer->Start();
82 void HistogramTimer::Start() { 82 if (isolate) Logger::CallEventLogger(isolate, name(), Logger::START, true);
83 if (Enabled()) {
84 timer_.Start();
85 }
86 Logger::CallEventLogger(counters()->isolate(), name(), Logger::START, true);
87 } 83 }
88 84
85 void TimedHistogram::Stop(base::ElapsedTimer* timer, Isolate* isolate) {
86 if (Enabled()) {
Camillo Bruni 2017/06/12 08:14:03 Given that this might be slightly performance crit
kschimpf 2017/06/12 16:47:04 This was previously in HistogramTimer as non-inlin
Camillo Bruni 2017/06/22 07:26:13 SGTM, let's see how this behaves in general first.
87 // Compute the delta between start and stop, in microseconds.
88 int64_t sample = resolution_ == HistogramTimerResolution::MICROSECOND
89 ? timer->Elapsed().InMicroseconds()
90 : timer->Elapsed().InMilliseconds();
91 timer->Stop();
92 AddSample(static_cast<int>(sample));
93 }
94 if (isolate != nullptr)
Camillo Bruni 2017/06/12 08:14:03 nit: style violation, please add braces.
kschimpf 2017/06/12 16:47:04 Done.
95 Logger::CallEventLogger(isolate, name(), Logger::END, true);
96 }
89 97
90 // Stop the timer and record the results. 98 void HistogramTimer::Start() {
99 TimedHistogram::Start(&timer_, counters()->isolate());
100 }
101
91 void HistogramTimer::Stop() { 102 void HistogramTimer::Stop() {
92 if (Enabled()) { 103 TimedHistogram::Stop(&timer_, counters()->isolate());
93 int64_t sample = resolution_ == MICROSECOND
94 ? timer_.Elapsed().InMicroseconds()
95 : timer_.Elapsed().InMilliseconds();
96 // Compute the delta between start and stop, in microseconds.
97 AddSample(static_cast<int>(sample));
98 timer_.Stop();
99 }
100 Logger::CallEventLogger(counters()->isolate(), name(), Logger::END, true);
101 } 104 }
102 105
103 Counters::Counters(Isolate* isolate) 106 Counters::Counters(Isolate* isolate)
104 : isolate_(isolate), 107 : isolate_(isolate),
105 stats_table_(this), 108 stats_table_(this),
106 // clang format off 109 // clang format off
107 #define SC(name, caption) name##_(this, "c:" #caption), 110 #define SC(name, caption) name##_(this, "c:" #caption),
108 STATS_COUNTER_TS_LIST(SC) 111 STATS_COUNTER_TS_LIST(SC)
109 #undef SC 112 #undef SC
110 // clang format on 113 // clang format on
(...skipping 13 matching lines...) Expand all
124 for (const auto& histogram : kHistograms) { 127 for (const auto& histogram : kHistograms) {
125 this->*histogram.member = 128 this->*histogram.member =
126 Histogram(histogram.caption, histogram.min, histogram.max, 129 Histogram(histogram.caption, histogram.min, histogram.max,
127 histogram.num_buckets, this); 130 histogram.num_buckets, this);
128 } 131 }
129 132
130 static const struct { 133 static const struct {
131 HistogramTimer Counters::*member; 134 HistogramTimer Counters::*member;
132 const char* caption; 135 const char* caption;
133 int max; 136 int max;
134 HistogramTimer::Resolution res; 137 HistogramTimerResolution res;
135 } kHistogramTimers[] = { 138 } kHistogramTimers[] = {
136 #define HT(name, caption, max, res) \ 139 #define HT(name, caption, max, res) \
137 {&Counters::name##_, #caption, max, HistogramTimer::res}, 140 {&Counters::name##_, #caption, max, HistogramTimerResolution::res},
138 HISTOGRAM_TIMER_LIST(HT) 141 HISTOGRAM_TIMER_LIST(HT)
139 #undef HT 142 #undef HT
140 }; 143 };
141 for (const auto& timer : kHistogramTimers) { 144 for (const auto& timer : kHistogramTimers) {
142 this->*timer.member = 145 this->*timer.member =
143 HistogramTimer(timer.caption, 0, timer.max, timer.res, 50, this); 146 HistogramTimer(timer.caption, 0, timer.max, timer.res, 50, this);
144 } 147 }
145 148
146 static const struct { 149 static const struct {
150 TimedHistogram Counters::*member;
151 const char* caption;
152 int max;
153 HistogramTimerResolution res;
154 } kTimedHistograms[] = {
155 #define HT(name, caption, max, res) \
156 {&Counters::name##_, #caption, max, HistogramTimerResolution::res},
157 TIMED_HISTOGRAM_LIST(HT)
158 #undef HT
159 };
160 for (const auto& timer : kTimedHistograms) {
161 this->*timer.member =
162 TimedHistogram(timer.caption, 0, timer.max, timer.res, 50, this);
163 }
164
165 static const struct {
147 AggregatableHistogramTimer Counters::*member; 166 AggregatableHistogramTimer Counters::*member;
148 const char* caption; 167 const char* caption;
149 } kAggregatableHistogramTimers[] = { 168 } kAggregatableHistogramTimers[] = {
150 #define AHT(name, caption) {&Counters::name##_, #caption}, 169 #define AHT(name, caption) {&Counters::name##_, #caption},
151 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) 170 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT)
152 #undef AHT 171 #undef AHT
153 }; 172 };
154 for (const auto& aht : kAggregatableHistogramTimers) { 173 for (const auto& aht : kAggregatableHistogramTimers) {
155 this->*aht.member = 174 this->*aht.member =
156 AggregatableHistogramTimer(aht.caption, 0, 10000000, 50, this); 175 AggregatableHistogramTimer(aht.caption, 0, 10000000, 50, this);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 stats_table_.SetCreateHistogramFunction(f); 306 stats_table_.SetCreateHistogramFunction(f);
288 307
289 #define HR(name, caption, min, max, num_buckets) name##_.Reset(); 308 #define HR(name, caption, min, max, num_buckets) name##_.Reset();
290 HISTOGRAM_RANGE_LIST(HR) 309 HISTOGRAM_RANGE_LIST(HR)
291 #undef HR 310 #undef HR
292 311
293 #define HT(name, caption, max, res) name##_.Reset(); 312 #define HT(name, caption, max, res) name##_.Reset();
294 HISTOGRAM_TIMER_LIST(HT) 313 HISTOGRAM_TIMER_LIST(HT)
295 #undef HT 314 #undef HT
296 315
316 #define HT(name, caption, max, res) name##_.Reset();
317 TIMED_HISTOGRAM_LIST(HT)
318 #undef HT
319
297 #define AHT(name, caption) name##_.Reset(); 320 #define AHT(name, caption) name##_.Reset();
298 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) 321 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT)
299 #undef AHT 322 #undef AHT
300 323
301 #define HP(name, caption) name##_.Reset(); 324 #define HP(name, caption) name##_.Reset();
302 HISTOGRAM_PERCENTAGE_LIST(HP) 325 HISTOGRAM_PERCENTAGE_LIST(HP)
303 #undef HP 326 #undef HP
304 327
305 #define HM(name, caption) name##_.Reset(); 328 #define HM(name, caption) name##_.Reset();
306 HISTOGRAM_LEGACY_MEMORY_LIST(HM) 329 HISTOGRAM_LEGACY_MEMORY_LIST(HM)
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 RuntimeCallStats::counters) { 577 RuntimeCallStats::counters) {
555 RuntimeCallCounter* counter = &(this->*counter_id); 578 RuntimeCallCounter* counter = &(this->*counter_id);
556 if (counter->count() > 0) counter->Dump(value); 579 if (counter->count() > 0) counter->Dump(value);
557 } 580 }
558 581
559 in_use_ = false; 582 in_use_ = false;
560 } 583 }
561 584
562 } // namespace internal 585 } // namespace internal
563 } // namespace v8 586 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698