OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2010 the V8 project authors. All rights reserved. | 3 # Copyright 2010 the V8 project authors. All rights reserved. |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 212 |
213 return charts | 213 return charts |
214 | 214 |
215 def reclaimed_bytes(row): | 215 def reclaimed_bytes(row): |
216 return row['total_size_before'] - row['total_size_after'] | 216 return row['total_size_before'] - row['total_size_after'] |
217 | 217 |
218 def other_scope(r): | 218 def other_scope(r): |
219 if r['gc'] == 's': | 219 if r['gc'] == 's': |
220 # there is no 'other' scope for scavenging collections. | 220 # there is no 'other' scope for scavenging collections. |
221 return 0 | 221 return 0 |
222 return r['pause'] - r['mark'] - r['sweep'] - r['compact'] - r['external'] | 222 return r['pause'] - r['mark'] - r['sweep'] - r['external'] |
223 | 223 |
224 def scavenge_scope(r): | 224 def scavenge_scope(r): |
225 if r['gc'] == 's': | 225 if r['gc'] == 's': |
226 return r['pause'] - r['external'] | 226 return r['pause'] - r['external'] |
227 return 0 | 227 return 0 |
228 | 228 |
229 | 229 |
230 def real_mutator(r): | 230 def real_mutator(r): |
231 return r['mutator'] - r['stepstook'] | 231 return r['mutator'] - r['stepstook'] |
232 | 232 |
233 plots = [ | 233 plots = [ |
234 [ | 234 [ |
235 Set('style fill solid 0.5 noborder'), | 235 Set('style fill solid 0.5 noborder'), |
236 Set('style histogram rowstacked'), | 236 Set('style histogram rowstacked'), |
237 Set('style data histograms'), | 237 Set('style data histograms'), |
238 Plot(Item('Scavenge', scavenge_scope, lc = 'green'), | 238 Plot(Item('Scavenge', scavenge_scope, lc = 'green'), |
239 Item('Marking', 'mark', lc = 'purple'), | 239 Item('Marking', 'mark', lc = 'purple'), |
240 Item('Sweep', 'sweep', lc = 'blue'), | 240 Item('Sweep', 'sweep', lc = 'blue'), |
241 Item('Compaction', 'compact', lc = 'red'), | |
242 Item('External', 'external', lc = '#489D43'), | 241 Item('External', 'external', lc = '#489D43'), |
243 Item('Other', other_scope, lc = 'grey'), | 242 Item('Other', other_scope, lc = 'grey'), |
244 Item('IGC Steps', 'stepstook', lc = '#FF6347')) | 243 Item('IGC Steps', 'stepstook', lc = '#FF6347')) |
245 ], | 244 ], |
246 [ | 245 [ |
247 Set('style fill solid 0.5 noborder'), | 246 Set('style fill solid 0.5 noborder'), |
248 Set('style histogram rowstacked'), | 247 Set('style histogram rowstacked'), |
249 Set('style data histograms'), | 248 Set('style data histograms'), |
250 Plot(Item('Scavenge', scavenge_scope, lc = 'green'), | 249 Plot(Item('Scavenge', scavenge_scope, lc = 'green'), |
251 Item('Marking', 'mark', lc = 'purple'), | 250 Item('Marking', 'mark', lc = 'purple'), |
252 Item('Sweep', 'sweep', lc = 'blue'), | 251 Item('Sweep', 'sweep', lc = 'blue'), |
253 Item('Compaction', 'compact', lc = 'red'), | |
254 Item('External', 'external', lc = '#489D43'), | 252 Item('External', 'external', lc = '#489D43'), |
255 Item('Other', other_scope, lc = '#ADD8E6'), | 253 Item('Other', other_scope, lc = '#ADD8E6'), |
256 Item('External', 'external', lc = '#D3D3D3')) | 254 Item('External', 'external', lc = '#D3D3D3')) |
257 ], | 255 ], |
258 | 256 |
259 [ | 257 [ |
260 Plot(Item('Mutator', real_mutator, lc = 'black', style = 'lines')) | 258 Plot(Item('Mutator', real_mutator, lc = 'black', style = 'lines')) |
261 ], | 259 ], |
262 [ | 260 [ |
263 Set('style histogram rowstacked'), | 261 Set('style histogram rowstacked'), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 return freduce(lambda t,r: max(t, r), field, trace, 0) | 300 return freduce(lambda t,r: max(t, r), field, trace, 0) |
303 | 301 |
304 def count_nonzero(trace, field): | 302 def count_nonzero(trace, field): |
305 return freduce(lambda t,r: t if r == 0 else t + 1, field, trace, 0) | 303 return freduce(lambda t,r: t if r == 0 else t + 1, field, trace, 0) |
306 | 304 |
307 | 305 |
308 def process_trace(filename): | 306 def process_trace(filename): |
309 trace = parse_gc_trace(filename) | 307 trace = parse_gc_trace(filename) |
310 | 308 |
311 marksweeps = filter(lambda r: r['gc'] == 'ms', trace) | 309 marksweeps = filter(lambda r: r['gc'] == 'ms', trace) |
312 markcompacts = filter(lambda r: r['gc'] == 'mc', trace) | |
313 scavenges = filter(lambda r: r['gc'] == 's', trace) | 310 scavenges = filter(lambda r: r['gc'] == 's', trace) |
314 globalgcs = filter(lambda r: r['gc'] != 's', trace) | 311 globalgcs = filter(lambda r: r['gc'] != 's', trace) |
315 | 312 |
316 | 313 |
317 charts = plot_all(plots, trace, filename) | 314 charts = plot_all(plots, trace, filename) |
318 | 315 |
319 def stats(out, prefix, trace, field): | 316 def stats(out, prefix, trace, field): |
320 n = len(trace) | 317 n = len(trace) |
321 total = calc_total(trace, field) | 318 total = calc_total(trace, field) |
322 max = calc_max(trace, field) | 319 max = calc_max(trace, field) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 358 |
362 | 359 |
363 with open(filename + '.html', 'w') as out: | 360 with open(filename + '.html', 'w') as out: |
364 out.write('<html><body>') | 361 out.write('<html><body>') |
365 out.write('<table>') | 362 out.write('<table>') |
366 out.write('<tr><td>Phase</td><td>Count</td><td>Time (ms)</td>') | 363 out.write('<tr><td>Phase</td><td>Count</td><td>Time (ms)</td>') |
367 out.write('<td>Max</td><td>Avg</td></tr>') | 364 out.write('<td>Max</td><td>Avg</td></tr>') |
368 stats(out, 'Total in GC', trace, 'pause') | 365 stats(out, 'Total in GC', trace, 'pause') |
369 stats(out, 'Scavenge', scavenges, 'pause') | 366 stats(out, 'Scavenge', scavenges, 'pause') |
370 stats(out, 'MarkSweep', marksweeps, 'pause') | 367 stats(out, 'MarkSweep', marksweeps, 'pause') |
371 stats(out, 'MarkCompact', markcompacts, 'pause') | |
372 stats(out, 'Mark', filter(lambda r: r['mark'] != 0, trace), 'mark') | 368 stats(out, 'Mark', filter(lambda r: r['mark'] != 0, trace), 'mark') |
373 stats(out, 'Sweep', filter(lambda r: r['sweep'] != 0, trace), 'sweep') | 369 stats(out, 'Sweep', filter(lambda r: r['sweep'] != 0, trace), 'sweep') |
374 stats(out, 'Compact', filter(lambda r: r['compact'] != 0, trace), 'compact') | |
375 stats(out, | 370 stats(out, |
376 'External', | 371 'External', |
377 filter(lambda r: r['external'] != 0, trace), | 372 filter(lambda r: r['external'] != 0, trace), |
378 'external') | 373 'external') |
379 out.write('</table>') | 374 out.write('</table>') |
380 throughput('TOTAL', trace) | 375 throughput('TOTAL', trace) |
381 throughput('MS', marksweeps) | 376 throughput('MS', marksweeps) |
382 throughput('MC', markcompacts) | |
383 throughput('OLDSPACE', globalgcs) | 377 throughput('OLDSPACE', globalgcs) |
384 out.write('<br/>') | 378 out.write('<br/>') |
385 for chart in charts: | 379 for chart in charts: |
386 out.write('<img src="%s">' % chart) | 380 out.write('<img src="%s">' % chart) |
387 out.write('</body></html>') | 381 out.write('</body></html>') |
388 | 382 |
389 print "%s generated." % (filename + '.html') | 383 print "%s generated." % (filename + '.html') |
390 | 384 |
391 if len(sys.argv) != 2: | 385 if len(sys.argv) != 2: |
392 print "Usage: %s <GC-trace-filename>" % sys.argv[0] | 386 print "Usage: %s <GC-trace-filename>" % sys.argv[0] |
393 sys.exit(1) | 387 sys.exit(1) |
394 | 388 |
395 process_trace(sys.argv[1]) | 389 process_trace(sys.argv[1]) |
OLD | NEW |