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

Side by Side Diff: tools/plot-timer-events.js

Issue 11414086: Add parallel recompilation time to histogram and plot execution pause times. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « tools/plot-timer-events ('k') | tools/tickprocessor.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var TimerEvents = {
29 'V8.ScriptRun' :
30 { ranges: [], color: "#444444", pause: false, index: 1 },
31 'V8.Compile' :
32 { ranges: [], color: "#CC0000", pause: true, index: 2 },
33 'V8.CompileLazy' :
34 { ranges: [], color: "#CC4400", pause: true, index: 3 },
35 'V8.CompileEval' :
36 { ranges: [], color: "#CC0044", pause: true, index: 4 },
37 'V8.CompileParallel':
38 { ranges: [], color: "#CC4444", pause: true, index: 5 },
39 'V8.Parse' :
40 { ranges: [], color: "#00CC00", pause: true, index: 6 },
41 'V8.PreParse' :
42 { ranges: [], color: "#44CC00", pause: true, index: 7 },
43 'V8.ParseLazy' :
44 { ranges: [], color: "#00CC44", pause: true, index: 8 },
45 'V8.GCScavenger' :
46 { ranges: [], color: "#0044CC", pause: true, index: 9 },
47 'V8.GCCompactor' :
48 { ranges: [], color: "#4444CC", pause: true, index: 10 },
49 'V8.GCContext' :
50 { ranges: [], color: "#4400CC", pause: true, index: 11 },
51 }
52
53
54 var kBarWidth = 0.33;
55 var kMergeTolerance = 0.05;
56 var kY1Offset = 3;
57 var kY2Factor = 5;
58 var kResX = 1600;
59 var kResY = 500;
60 var kLabelPadding = 5;
61 var kNumPauseLabels = 7;
62
63 var xrange = 0;
64 var obj_index = 0;
65 var execution_pauses = [];
66
67 function Range(start, end) {
68 // Everthing from here are in milliseconds.
69 this.start = start;
70 this.end = end;
71 }
72
73 Range.prototype.duration = function() { return this.end - this.start; }
74
75
76 function ProcessTimerEvent(name, start, length) {
77 var event = TimerEvents[name];
78 if (event === undefined) return;
79 start /= 1000; // Convert to milliseconds.
80 length /= 1000;
81 var end = start + length;
82 event.ranges.push(new Range(start, end));
83 if (end > xrange) xrange = end;
84 }
85
86
87 function CollectData() {
88 // Collect data from log.
89 var logreader = new LogReader(
90 { 'timer-event' : { parsers: [null, parseInt, parseInt],
91 processor: ProcessTimerEvent
92 } });
93
94 var line;
95 while (line = readline()) {
96 logreader.processLogLine(line);
97 }
98
99 // Collect execution pauses.
100 for (name in TimerEvents) {
101 var event = TimerEvents[name];
102 if (!event.pause) continue;
103 var ranges = event.ranges;
104 // Add ranges of this event to the pause list.
105 for (var j = 0; j < ranges.length; j++) {
106 execution_pauses.push(ranges[j]);
107 }
108 }
109 }
110
111
112 function drawBar(row, color, start, end) {
113 obj_index++;
114 command = "set object " + obj_index + " rect";
115 command += " from " + start + ", " + (row - kBarWidth + kY1Offset);
116 command += " to " + end + ", " + (row + kBarWidth + kY1Offset);
117 command += " fc rgb \"" + color + "\"";
118 print(command);
119 }
120
121
122 function MergeRanges(ranges, merge_tolerance) {
123 ranges.sort(function(a, b) { return a.start - b.start; });
124 var result = [];
125 var j = 0;
126 for (var i = 0; i < ranges.length; i = j) {
127 var merge_start = ranges[i].start;
128 var merge_end = ranges[i].end;
129 for (j = i + 1; j < ranges.length; j++) {
130 var next_range = ranges[j];
131 // Don't merge ranges if there is no overlap.
132 if (next_range.start >= merge_end + kMergeTolerance) break;
133 // Merge ranges.
134 if ((next_range.end > merge_end)) { // Extend range end.
135 merge_end = next_range.end;
136 }
137 }
138 result.push(new Range(merge_start, merge_end));
139 }
140 return result;
141 }
142
143
144 function GnuplotOutput() {
145 print("set terminal pngcairo size 1600,400 enhanced font 'Helvetica,10'");
146 print("set yrange [0:15]");
147 print("set xlabel \"execution time in ms\"");
148 print("set xrange [0:" + xrange + "]");
149 print("set style fill pattern 2 bo 1");
150 print("set style rect fc lt -1 fs solid 1 noborder");
151 print("set style line 1 lt 1 lw 1 lc rgb \"#000000\"");
152 print("set xtics out nomirror");
153 print("unset key");
154
155 // Name Y-axis.
156 var ytics = [];
157 for (name in TimerEvents) {
158 var index = TimerEvents[name].index;
159 ytics.push('"' + name + '"' + ' ' + (index + kY1Offset));
160 }
161 print("set ytics out nomirror (" + ytics.join(', ') + ")");
162
163 // Smallest visible gap given our resolution.
164 // We remove superfluous objects to go easy on Gnuplot.
165 var visible_gap = xrange / kResX / 2;
166
167 // Plot timeline.
168 for (var name in TimerEvents) {
169 var event = TimerEvents[name];
170 var ranges = MergeRanges(event.ranges, visible_gap);
171 for (var i = 0; i < ranges.length; i++) {
172 drawBar(event.index, event.color, ranges[i].start, ranges[i].end);
173 }
174 }
175
176 if (execution_pauses.length == 0) {
177 print("plot 1/0");
178 return;
179 }
180
181 // Exclude execution pauses from the execution timeline.
182 var execution_row = TimerEvents['V8.ScriptRun'].index;
183 exclude_ranges = MergeRanges(execution_pauses,
184 Math.max(visible_gap, kMergeTolerance));
185 for (var i = 0; i < exclude_ranges.length; i++) {
186 var pause = execution_pauses[i];
187 drawBar(execution_row, "#FFFFFF", pause.start, pause.end);
188 }
189
190
191 // Plot execution pauses as impulses. This may be better resolved
192 // due to possibly smaller merge tolerance.
193 execution_pauses = MergeRanges(execution_pauses, kMergeTolerance);
194
195 // Label the longest pauses.
196 execution_pauses.sort(
197 function(a, b) { return b.duration() - a.duration(); });
198
199 var max_pause_time = execution_pauses[0].duration();
200 var padding = kLabelPadding * xrange / kResX;
201 var y_scale = kY1Offset / max_pause_time;
202 for (var i = 0; i < execution_pauses.length && i < kNumPauseLabels; i++) {
203 var pause = execution_pauses[i];
204 var label_content = (pause.duration() | 0) + " ms";
205 var label_x = pause.end + padding;
206 var label_y = Math.max(1, (pause.duration() * y_scale));
207 print("set label \"" + label_content + "\" at " +
208 label_x + "," + label_y + " font \"Helvetica,7'\"");
209 }
210
211 // Scale second Y-axis appropriately.
212 print("set y2range [0:" + (max_pause_time * kY2Factor) + "]");
213
214 print("plot '-' using 1:2 axes x1y2 with impulses ls 1");
215 for (var i = 0; i < execution_pauses.length; i++) {
216 var pause = execution_pauses[i];
217 print(pause.end + " " + pause.duration());
218 }
219 print("e");
220 }
221
222 CollectData();
223 GnuplotOutput();
224
OLDNEW
« no previous file with comments | « tools/plot-timer-events ('k') | tools/tickprocessor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698