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

Side by Side Diff: runtime/tools/verbose_gc_to_bmu.dart

Issue 1133243004: Tool to compute BMU plots from GC logs. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/tools/bmu_benchmark_gallery.sh ('k') | tests/standalone/verbose_gc_to_bmu_test.dart » ('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 (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Tool to compute bounded mutator utilization (BMU) from a --verbose_gc log.
6 // Outputs CSV suitable for, e.g., gnuplot:
7 //
8 // dart --verbose_gc foo.dart 2> foo.gclog
9 // dart verbose_gc_to_bmu.dart < foo.gclog > foo.bmu
10 // gnuplot -p -e "set yr [0:1]; set logscale x; plot 'foo.bmu' with linespoints"
11
12 import 'dart:io';
13 import 'dart:math';
14
15 const WINDOW_STEP_FACTOR = 0.9;
16 const MINIMUM_WINDOW_SIZE_MS = 1;
17
18 class Interval<T> {
19 T begin;
20 T end;
21 Interval(this.begin, this.end);
22 T get length => max(0, end - begin);
23 Interval<T> overlap(Interval<T> other) =>
24 new Interval(max(this.begin, other.begin), min(this.end, other.end));
25 }
26
27 class Timeline {
28 // Pauses must be added in non-decreasing order of 'begin'.
29 void addPause(Interval<int> pause) {
30 var last = _pauses.isEmpty ? new Interval<int>(0, 0) : _pauses.last;
31 assert(last.begin <= pause.begin);
32 // Trim any initial overlap.
33 _pauses.add(new Interval(max(pause.begin, last.end), pause.end));
34 // TODO(koda): Make VM log actual end time, rather than just last GC end.
35 _run.end = max(_run.end, pause.end);
36 }
37
38 int get maxWindowSize => _run.length;
39
40 // The windowSize must be no larger than the entire run.
41 double minUtilization(int windowSize) {
42 assert(windowSize <= _run.length);
43 // The minimum utilization can always be found in a window that has one of
44 // its endpoints at the beginning or end of a pause or the entire timeline.
45 List<int> interesting = [_run.begin, _run.end];
46 for (Interval p in _pauses) {
47 interesting.add(p.begin);
48 interesting.add(p.end);
49 }
50 double result = 1.0;
51 for (int i in interesting) {
52 result = min(result, _utilization(new Interval(i, i + windowSize)));
53 result = min(result, _utilization(new Interval(i - windowSize, i)));
54 }
55 return result;
56 }
57
58 // Returns the fraction of non-pause time, or 1.0 for an invalid interval.
59 double _utilization(Interval<int> iv) {
60 if (_run.begin > iv.begin || iv.end > _run.end || iv.length == 0) {
61 return 1.0;
62 }
63 int paused = 0;
64 for (Interval<int> p in _pauses) {
65 paused += p.overlap(iv).length;
66 }
67 return 1.0 - (paused / iv.length);
68 }
69
70 final Interval<int> _run = new Interval<int>(0, 0);
71 final List<Interval<int>> _pauses = [];
72 }
73
74 // Returns a GC pause as an interval in microseconds since program start, or
75 // the interval [0, 0) on parse error.
76 Interval<int> parseVerboseGCLine(String line) {
77 var fields = line.split(',');
78 // Update this (and indices below, if needed) when logging format changes.
79 if (fields.length != 25) {
80 assert(line.startsWith('[ GC | space | count | start | gc time') ||
81 line.startsWith('[ (isolate)| (reason)| | (s) | (ms) '));
82 return new Interval<int>(0, 0);
83 }
84 var begin = (1e6 * double.parse(fields[2])).floor();
85 var duration = (1000 * double.parse(fields[3])).floor();
86 var end = begin + duration;
87 return new Interval<int>(begin, end);
88 }
89
90 void main() {
91 Timeline t = new Timeline();
92 for (String line = stdin.readLineSync();
93 line != null;
94 line = stdin.readLineSync()) {
95 t.addPause(parseVerboseGCLine(line));
96 }
97 print('# window_size_ms, bounded_mutator_utilization');
98 var minimumSeen = 1.0;
99 for (int w = t._run.length;
100 w > 1000 * MINIMUM_WINDOW_SIZE_MS;
101 w = (w * WINDOW_STEP_FACTOR).floor()) {
102 minimumSeen = min(minimumSeen, t.minUtilization(w));
103 print('${w / 1000}, $minimumSeen');
104 }
105 }
OLDNEW
« no previous file with comments | « runtime/tools/bmu_benchmark_gallery.sh ('k') | tests/standalone/verbose_gc_to_bmu_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698