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

Side by Side Diff: src/compiler-dispatcher/compiler-dispatcher-tracer.h

Issue 2413243002: Introduce a CompilerDispatcherTracer and track how long jobs take (Closed)
Patch Set: Created 4 years, 2 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
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_TRACER_H_
6 #define V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_TRACER_H_
7
8 #include <utility>
9
10 #include "src/base/macros.h"
11 #include "src/base/platform/mutex.h"
12 #include "src/base/ring-buffer.h"
13 #include "src/counters.h"
14
15 namespace v8 {
16 namespace internal {
17
18 class Isolate;
19 class RuntimeCallStats;
20
21 #define COMPILER_DISPATCHER_TRACE_SCOPE_WITH_NUM(tracer, scope_id, num) \
22 CompilerDispatcherTracer::ScopeID tracer_scope_id( \
23 CompilerDispatcherTracer::ScopeID::scope_id); \
24 CompilerDispatcherTracer::Scope trace_scope(tracer, tracer_scope_id, num); \
25 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), \
26 CompilerDispatcherTracer::Scope::Name(tracer_scope_id))
27
28 #define COMPILER_DISPATCHER_TRACE_SCOPE(tracer, scope_id) \
29 COMPILER_DISPATCHER_TRACE_SCOPE_WITH_NUM(tracer, scope_id, 0)
30
31 class CompilerDispatcherTracer {
32 public:
33 enum class ScopeID {
34 kPrepareToParse,
35 kParse,
36 kFinalizeParsing,
37 kPrepareToCompile,
38 kCompile,
39 kFinalizeCompiling
40 };
41
42 class Scope {
43 public:
44 Scope(CompilerDispatcherTracer* tracer, ScopeID scope_id, size_t num = 0);
45 ~Scope();
46
47 static const char* Name(ScopeID scoped_id);
48
49 private:
50 CompilerDispatcherTracer* tracer_;
51 ScopeID scope_id_;
52 size_t num_;
53 double start_time_;
54 RuntimeCallTimer timer_;
55
56 DISALLOW_COPY_AND_ASSIGN(Scope);
57 };
58
59 explicit CompilerDispatcherTracer(Isolate* isolate);
60 ~CompilerDispatcherTracer();
61
62 void RecordPrepareToParse(double duration_ms);
63 void RecordParse(double duration_ms, size_t source_length);
64 void RecordFinalizeParsing(double duration_ms);
65 void RecordPrepareToCompile(double duration_ms);
66 void RecordCompile(double duration_ms, size_t ast_size_in_bytes);
67 void RecordFinalizeCompiling(double duration_ms);
68
69 double EstimatePrepareToParse() const;
ulan 2016/10/13 16:56:07 nit: I would add *TimeInMs to all these functions,
70 double EstimateParse(size_t source_length) const;
71 double EstimateFinalizeParsing();
72 double EstimatePrepareToCompile();
73 double EstimateCompile(size_t ast_size_in_bytes);
74 double EstimateFinalizeCompiling();
75
76 private:
77 static double Average(const base::RingBuffer<double>& buffer);
78 static double Estimate(
79 const base::RingBuffer<std::pair<size_t, double>>& buffer, size_t num);
80
81 mutable base::Mutex mutex_;
82 base::RingBuffer<double> prepare_parse_events_;
83 base::RingBuffer<std::pair<size_t, double>> parse_events_;
84 base::RingBuffer<double> finalize_parsing_events_;
85 base::RingBuffer<double> prepare_compile_events_;
86 base::RingBuffer<std::pair<size_t, double>> compile_events_;
87 base::RingBuffer<double> finalize_compiling_events_;
88
89 RuntimeCallStats* runtime_call_stats_;
90
91 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherTracer);
92 };
93
94 } // namespace internal
95 } // namespace v8
96
97 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_TRACER_H_
OLDNEW
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher-job.cc ('k') | src/compiler-dispatcher/compiler-dispatcher-tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698