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

Side by Side Diff: src/counters.h

Issue 875873002: Rescale histogram timers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: only change compilation-related histograms Created 5 years, 11 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
« no previous file with comments | « no previous file | src/counters.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef V8_COUNTERS_H_ 5 #ifndef V8_COUNTERS_H_
6 #define V8_COUNTERS_H_ 6 #define V8_COUNTERS_H_
7 7
8 #include "include/v8.h" 8 #include "include/v8.h"
9 #include "src/allocation.h" 9 #include "src/allocation.h"
10 #include "src/base/platform/elapsed-timer.h" 10 #include "src/base/platform/elapsed-timer.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 int max_; 217 int max_;
218 int num_buckets_; 218 int num_buckets_;
219 void* histogram_; 219 void* histogram_;
220 bool lookup_done_; 220 bool lookup_done_;
221 Isolate* isolate_; 221 Isolate* isolate_;
222 }; 222 };
223 223
224 // A HistogramTimer allows distributions of results to be created. 224 // A HistogramTimer allows distributions of results to be created.
225 class HistogramTimer : public Histogram { 225 class HistogramTimer : public Histogram {
226 public: 226 public:
227 HistogramTimer() { } 227 enum Resolution {
228 HistogramTimer(const char* name, 228 MILLISECOND,
229 int min, 229 MICROSECOND
230 int max, 230 };
231 int num_buckets, 231
232 Isolate* isolate) 232 HistogramTimer() {}
233 : Histogram(name, min, max, num_buckets, isolate) {} 233 HistogramTimer(const char* name, int min, int max, Resolution resolution,
234 int num_buckets, Isolate* isolate)
235 : Histogram(name, min, max, num_buckets, isolate),
236 resolution_(resolution) {}
234 237
235 // Start the timer. 238 // Start the timer.
236 void Start(); 239 void Start();
237 240
238 // Stop the timer and record the results. 241 // Stop the timer and record the results.
239 void Stop(); 242 void Stop();
240 243
241 // Returns true if the timer is running. 244 // Returns true if the timer is running.
242 bool Running() { 245 bool Running() {
243 return Enabled() && timer_.IsStarted(); 246 return Enabled() && timer_.IsStarted();
244 } 247 }
245 248
246 // TODO(bmeurer): Remove this when HistogramTimerScope is fixed. 249 // TODO(bmeurer): Remove this when HistogramTimerScope is fixed.
247 #ifdef DEBUG 250 #ifdef DEBUG
248 base::ElapsedTimer* timer() { return &timer_; } 251 base::ElapsedTimer* timer() { return &timer_; }
249 #endif 252 #endif
250 253
251 private: 254 private:
252 base::ElapsedTimer timer_; 255 base::ElapsedTimer timer_;
256 Resolution resolution_;
253 }; 257 };
254 258
255 // Helper class for scoping a HistogramTimer. 259 // Helper class for scoping a HistogramTimer.
256 // TODO(bmeurer): The ifdeffery is an ugly hack around the fact that the 260 // TODO(bmeurer): The ifdeffery is an ugly hack around the fact that the
257 // Parser is currently reentrant (when it throws an error, we call back 261 // Parser is currently reentrant (when it throws an error, we call back
258 // into JavaScript and all bets are off), but ElapsedTimer is not 262 // into JavaScript and all bets are off), but ElapsedTimer is not
259 // reentry-safe. Fix this properly and remove |allow_nesting|. 263 // reentry-safe. Fix this properly and remove |allow_nesting|.
260 class HistogramTimerScope BASE_EMBEDDED { 264 class HistogramTimerScope BASE_EMBEDDED {
261 public: 265 public:
262 explicit HistogramTimerScope(HistogramTimer* timer, 266 explicit HistogramTimerScope(HistogramTimer* timer,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // events to be timed. 312 // events to be timed.
309 class AggregatableHistogramTimer : public Histogram { 313 class AggregatableHistogramTimer : public Histogram {
310 public: 314 public:
311 AggregatableHistogramTimer() {} 315 AggregatableHistogramTimer() {}
312 AggregatableHistogramTimer(const char* name, int min, int max, 316 AggregatableHistogramTimer(const char* name, int min, int max,
313 int num_buckets, Isolate* isolate) 317 int num_buckets, Isolate* isolate)
314 : Histogram(name, min, max, num_buckets, isolate) {} 318 : Histogram(name, min, max, num_buckets, isolate) {}
315 319
316 // Start/stop the "outer" scope. 320 // Start/stop the "outer" scope.
317 void Start() { time_ = base::TimeDelta(); } 321 void Start() { time_ = base::TimeDelta(); }
318 void Stop() { AddSample(static_cast<int>(time_.InMilliseconds())); } 322 void Stop() { AddSample(static_cast<int>(time_.InMicroseconds())); }
319 323
320 // Add a time value ("inner" scope). 324 // Add a time value ("inner" scope).
321 void Add(base::TimeDelta other) { time_ += other; } 325 void Add(base::TimeDelta other) { time_ += other; }
322 326
323 private: 327 private:
324 base::TimeDelta time_; 328 base::TimeDelta time_;
325 }; 329 };
326 330
327 331
328 // A helper class for use with AggregatableHistogramTimer. 332 // A helper class for use with AggregatableHistogramTimer.
(...skipping 24 matching lines...) Expand all
353 AggregatableHistogramTimer* histogram_; 357 AggregatableHistogramTimer* histogram_;
354 }; 358 };
355 359
356 360
357 #define HISTOGRAM_RANGE_LIST(HR) \ 361 #define HISTOGRAM_RANGE_LIST(HR) \
358 /* Generic range histograms */ \ 362 /* Generic range histograms */ \
359 HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \ 363 HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \
360 HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \ 364 HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \
361 HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, 101) 365 HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, 101)
362 366
363 #define HISTOGRAM_TIMER_LIST(HT) \ 367 #define HISTOGRAM_TIMER_LIST(HT) \
364 /* Garbage collection timers. */ \ 368 /* Garbage collection timers. */ \
365 HT(gc_compactor, V8.GCCompactor) \ 369 HT(gc_compactor, V8.GCCompactor, 10000, MILLISECOND) \
366 HT(gc_scavenger, V8.GCScavenger) \ 370 HT(gc_scavenger, V8.GCScavenger, 10000, MILLISECOND) \
367 HT(gc_context, V8.GCContext) /* GC context cleanup time */ \ 371 HT(gc_context, V8.GCContext, 10000, \
368 HT(gc_idle_notification, V8.GCIdleNotification) \ 372 MILLISECOND) /* GC context cleanup time */ \
369 HT(gc_incremental_marking, V8.GCIncrementalMarking) \ 373 HT(gc_idle_notification, V8.GCIdleNotification, 10000, MILLISECOND) \
370 HT(gc_low_memory_notification, V8.GCLowMemoryNotification) \ 374 HT(gc_incremental_marking, V8.GCIncrementalMarking, 10000, MILLISECOND) \
371 /* Parsing timers. */ \ 375 HT(gc_low_memory_notification, V8.GCLowMemoryNotification, 10000, \
372 HT(parse, V8.Parse) \ 376 MILLISECOND) \
373 HT(parse_lazy, V8.ParseLazy) \ 377 /* Parsing timers. */ \
374 HT(pre_parse, V8.PreParse) \ 378 HT(parse, V8.ParseMicroSeconds, 1000000, MICROSECOND) \
375 /* Compilation times. */ \ 379 HT(parse_lazy, V8.ParseLazyMicroSeconds, 1000000, MICROSECOND) \
376 HT(compile, V8.Compile) \ 380 HT(pre_parse, V8.PreParseMicroSeconds, 1000000, MICROSECOND) \
377 HT(compile_eval, V8.CompileEval) \ 381 /* Compilation times. */ \
378 /* Serialization as part of compilation (code caching) */ \ 382 HT(compile, V8.CompileMicroSeconds, 1000000, MICROSECOND) \
379 HT(compile_serialize, V8.CompileSerialize) \ 383 HT(compile_eval, V8.CompileEvalMicroSeconds, 1000000, MICROSECOND) \
380 HT(compile_deserialize, V8.CompileDeserialize) \ 384 /* Serialization as part of compilation (code caching) */ \
381 /* Total compilation time incl. caching/parsing */ \ 385 HT(compile_serialize, V8.CompileSerializeMicroSeconds, 100000, MICROSECOND) \
382 HT(compile_script, V8.CompileScript) 386 HT(compile_deserialize, V8.CompileDeserializeMicroSeconds, 1000000, \
387 MICROSECOND) \
388 /* Total compilation time incl. caching/parsing */ \
389 HT(compile_script, V8.CompileScriptMicroSeconds, 1000000, MICROSECOND)
383 390
384 391
385 #define AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) \ 392 #define AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) \
386 AHT(compile_lazy, V8.CompileLazy) 393 AHT(compile_lazy, V8.CompileLazyMicroSeconds)
387 394
388 395
389 #define HISTOGRAM_PERCENTAGE_LIST(HP) \ 396 #define HISTOGRAM_PERCENTAGE_LIST(HP) \
390 /* Heap fragmentation. */ \ 397 /* Heap fragmentation. */ \
391 HP(external_fragmentation_total, \ 398 HP(external_fragmentation_total, \
392 V8.MemoryExternalFragmentationTotal) \ 399 V8.MemoryExternalFragmentationTotal) \
393 HP(external_fragmentation_old_pointer_space, \ 400 HP(external_fragmentation_old_pointer_space, \
394 V8.MemoryExternalFragmentationOldPointerSpace) \ 401 V8.MemoryExternalFragmentationOldPointerSpace) \
395 HP(external_fragmentation_old_data_space, \ 402 HP(external_fragmentation_old_data_space, \
396 V8.MemoryExternalFragmentationOldDataSpace) \ 403 V8.MemoryExternalFragmentationOldDataSpace) \
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 631
625 632
626 // This file contains all the v8 counters that are in use. 633 // This file contains all the v8 counters that are in use.
627 class Counters { 634 class Counters {
628 public: 635 public:
629 #define HR(name, caption, min, max, num_buckets) \ 636 #define HR(name, caption, min, max, num_buckets) \
630 Histogram* name() { return &name##_; } 637 Histogram* name() { return &name##_; }
631 HISTOGRAM_RANGE_LIST(HR) 638 HISTOGRAM_RANGE_LIST(HR)
632 #undef HR 639 #undef HR
633 640
634 #define HT(name, caption) \ 641 #define HT(name, caption, max, res) \
635 HistogramTimer* name() { return &name##_; } 642 HistogramTimer* name() { return &name##_; }
636 HISTOGRAM_TIMER_LIST(HT) 643 HISTOGRAM_TIMER_LIST(HT)
637 #undef HT 644 #undef HT
638 645
639 #define AHT(name, caption) \ 646 #define AHT(name, caption) \
640 AggregatableHistogramTimer* name() { return &name##_; } 647 AggregatableHistogramTimer* name() { return &name##_; }
641 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) 648 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT)
642 #undef AHT 649 #undef AHT
643 650
644 #define HP(name, caption) \ 651 #define HP(name, caption) \
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 688
682 #define SC(name) \ 689 #define SC(name) \
683 StatsCounter* count_of_CODE_AGE_##name() \ 690 StatsCounter* count_of_CODE_AGE_##name() \
684 { return &count_of_CODE_AGE_##name##_; } \ 691 { return &count_of_CODE_AGE_##name##_; } \
685 StatsCounter* size_of_CODE_AGE_##name() \ 692 StatsCounter* size_of_CODE_AGE_##name() \
686 { return &size_of_CODE_AGE_##name##_; } 693 { return &size_of_CODE_AGE_##name##_; }
687 CODE_AGE_LIST_COMPLETE(SC) 694 CODE_AGE_LIST_COMPLETE(SC)
688 #undef SC 695 #undef SC
689 696
690 enum Id { 697 enum Id {
691 #define RATE_ID(name, caption) k_##name, 698 #define RATE_ID(name, caption, max, res) k_##name,
692 HISTOGRAM_TIMER_LIST(RATE_ID) 699 HISTOGRAM_TIMER_LIST(RATE_ID)
693 #undef RATE_ID 700 #undef RATE_ID
694 #define AGGREGATABLE_ID(name, caption) k_##name, 701 #define AGGREGATABLE_ID(name, caption) k_##name,
695 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AGGREGATABLE_ID) 702 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AGGREGATABLE_ID)
696 #undef AGGREGATABLE_ID 703 #undef AGGREGATABLE_ID
697 #define PERCENTAGE_ID(name, caption) k_##name, 704 #define PERCENTAGE_ID(name, caption) k_##name,
698 HISTOGRAM_PERCENTAGE_LIST(PERCENTAGE_ID) 705 HISTOGRAM_PERCENTAGE_LIST(PERCENTAGE_ID)
699 #undef PERCENTAGE_ID 706 #undef PERCENTAGE_ID
700 #define MEMORY_ID(name, caption) k_##name, 707 #define MEMORY_ID(name, caption) k_##name,
701 HISTOGRAM_MEMORY_LIST(MEMORY_ID) 708 HISTOGRAM_MEMORY_LIST(MEMORY_ID)
(...skipping 21 matching lines...) Expand all
723 }; 730 };
724 731
725 void ResetCounters(); 732 void ResetCounters();
726 void ResetHistograms(); 733 void ResetHistograms();
727 734
728 private: 735 private:
729 #define HR(name, caption, min, max, num_buckets) Histogram name##_; 736 #define HR(name, caption, min, max, num_buckets) Histogram name##_;
730 HISTOGRAM_RANGE_LIST(HR) 737 HISTOGRAM_RANGE_LIST(HR)
731 #undef HR 738 #undef HR
732 739
733 #define HT(name, caption) \ 740 #define HT(name, caption, max, res) HistogramTimer name##_;
734 HistogramTimer name##_;
735 HISTOGRAM_TIMER_LIST(HT) 741 HISTOGRAM_TIMER_LIST(HT)
736 #undef HT 742 #undef HT
737 743
738 #define AHT(name, caption) \ 744 #define AHT(name, caption) \
739 AggregatableHistogramTimer name##_; 745 AggregatableHistogramTimer name##_;
740 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) 746 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT)
741 #undef AHT 747 #undef AHT
742 748
743 #define HP(name, caption) \ 749 #define HP(name, caption) \
744 Histogram name##_; 750 Histogram name##_;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 friend class Isolate; 789 friend class Isolate;
784 790
785 explicit Counters(Isolate* isolate); 791 explicit Counters(Isolate* isolate);
786 792
787 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters); 793 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters);
788 }; 794 };
789 795
790 } } // namespace v8::internal 796 } } // namespace v8::internal
791 797
792 #endif // V8_COUNTERS_H_ 798 #endif // V8_COUNTERS_H_
OLDNEW
« no previous file with comments | « no previous file | src/counters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698