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

Unified Diff: src/counters.h

Issue 2511093002: [counters] RuntimeStats: fix wrong bookkeeping when dynamically changing counters. (Closed)
Patch Set: moar tests Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: src/counters.h
diff --git a/src/counters.h b/src/counters.h
index 67c0be215d5b3d1a7b19440ae72afc31d3b21191..ab4aa2f654a6bf3d5c23e7d798a0ec05de9c24d4 100644
--- a/src/counters.h
+++ b/src/counters.h
@@ -249,7 +249,7 @@ class HistogramTimer : public Histogram {
// Stop the timer and record the results.
void Stop();
- // Returns true if the timer is running.
+ // Returns true if the timer is runnibase::ng.
Igor Sheludko 2016/11/18 18:56:27 Spurious change.
Camillo Bruni 2016/11/21 10:50:03 done.
bool Running() {
return Enabled() && timer_.IsStarted();
}
@@ -506,37 +506,12 @@ class RuntimeCallTimer {
private:
friend class RuntimeCallStats;
- inline void Start(RuntimeCallCounter* counter, RuntimeCallTimer* parent) {
- counter_ = counter;
- parent_.SetValue(parent);
- if (FLAG_runtime_stats !=
- v8::tracing::TracingCategoryObserver::ENABLED_BY_SAMPLING) {
- timer_.Start();
- }
- }
-
- inline RuntimeCallTimer* Stop() {
- if (!timer_.IsStarted()) return parent();
- base::TimeDelta delta = timer_.Elapsed();
- timer_.Stop();
- counter_->count++;
- counter_->time += delta;
- if (parent()) {
- // Adjust parent timer so that it does not include sub timer's time.
- parent()->counter_->time -= delta;
- }
- return parent();
- }
-
- inline void Elapsed() {
- base::TimeDelta delta = timer_.Elapsed();
- counter_->time += delta;
- if (parent()) {
- parent()->counter_->time -= delta;
- parent()->Elapsed();
- }
- timer_.Restart();
- }
+ inline void Start(RuntimeCallCounter* counter, RuntimeCallTimer* parent);
+ inline RuntimeCallTimer* Stop();
+ // Synchronize the currently active timer stack. Walk up the stack by stopping
+ // and restarting each timer.
+ inline void Snapshot();
+ inline void Subtract(base::TimeDelta delta);
const char* name() { return counter_->name; }
@@ -746,6 +721,8 @@ class RuntimeCallTimer {
V(PrototypeObject_DeleteProperty) \
V(RecompileConcurrent) \
V(RecompileSynchronous) \
+ V(TestCounter1) \
+ V(TestCounter2) \
/* Dummy counter for the unexpected stub miss. */ \
V(UnexpectedStubMiss)
@@ -892,6 +869,36 @@ class RuntimeCallStats : public ZoneObject {
CHANGE_CURRENT_RUNTIME_COUNTER(isolate->counters()->runtime_call_stats(), \
Handler_##counter_name)
+// A RuntimeCallTimerScopes wraps around a RuntimeCallTimer to measure the
+// the time of C++ scope.
+class RuntimeCallTimerScope {
+ public:
+ inline RuntimeCallTimerScope(Isolate* isolate,
+ RuntimeCallStats::CounterId counter_id);
+ // This constructor is here just to avoid calling GetIsolate() when the
+ // stats are disabled and the isolate is not directly available.
+ inline RuntimeCallTimerScope(HeapObject* heap_object,
+ RuntimeCallStats::CounterId counter_id);
+ inline RuntimeCallTimerScope(RuntimeCallStats* stats,
+ RuntimeCallStats::CounterId counter_id);
+
+ inline ~RuntimeCallTimerScope() {
+ if (V8_UNLIKELY(stats_ != nullptr)) {
+ RuntimeCallStats::Leave(stats_, &timer_);
+ }
+ }
+
+ private:
+ V8_INLINE void Initialize(RuntimeCallStats* stats,
+ RuntimeCallStats::CounterId counter_id) {
+ stats_ = stats;
+ RuntimeCallStats::Enter(stats_, &timer_, counter_id);
+ }
+
+ RuntimeCallStats* stats_ = nullptr;
+ RuntimeCallTimer timer_;
+};
+
#define HISTOGRAM_RANGE_LIST(HR) \
/* Generic range histograms */ \
HR(detached_context_age_in_gc, V8.DetachedContextAgeInGC, 0, 20, 21) \
@@ -1303,36 +1310,6 @@ class Counters {
DISALLOW_IMPLICIT_CONSTRUCTORS(Counters);
};
-// A RuntimeCallTimerScopes wraps around a RuntimeCallTimer to measure the
-// the time of C++ scope.
-class RuntimeCallTimerScope {
- public:
- inline RuntimeCallTimerScope(Isolate* isolate,
- RuntimeCallStats::CounterId counter_id);
- // This constructor is here just to avoid calling GetIsolate() when the
- // stats are disabled and the isolate is not directly available.
- inline RuntimeCallTimerScope(HeapObject* heap_object,
- RuntimeCallStats::CounterId counter_id);
- inline RuntimeCallTimerScope(RuntimeCallStats* stats,
- RuntimeCallStats::CounterId counter_id);
-
- inline ~RuntimeCallTimerScope() {
- if (V8_UNLIKELY(stats_ != nullptr)) {
- RuntimeCallStats::Leave(stats_, &timer_);
- }
- }
-
- private:
- V8_INLINE void Initialize(RuntimeCallStats* stats,
- RuntimeCallStats::CounterId counter_id) {
- stats_ = stats;
- RuntimeCallStats::Enter(stats_, &timer_, counter_id);
- }
-
- RuntimeCallStats* stats_ = nullptr;
- RuntimeCallTimer timer_;
-};
-
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698