Output time spent in code flushing in GC NVP trace.

Add support for flushcode scope and cumulative stats into gc-nvp-trace-processor.

Review URL: http://codereview.chromium.org/3054003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5102 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
vegorov@chromium.org 2010-07-20 10:59:00 +00:00
parent 6f69731a23
commit f32e2b7093
3 changed files with 45 additions and 7 deletions

View File

@ -638,6 +638,7 @@ void Heap::PerformGarbageCollection(AllocationSpace space,
if (collector == MARK_COMPACTOR) {
if (FLAG_flush_code) {
// Flush all potentially unused code.
GCTracer::Scope gc_scope(tracer, GCTracer::Scope::MC_FLUSH_CODE);
FlushCode();
}
@ -4841,6 +4842,7 @@ GCTracer::~GCTracer() {
PrintF("mark=%d ", static_cast<int>(scopes_[Scope::MC_MARK]));
PrintF("sweep=%d ", static_cast<int>(scopes_[Scope::MC_SWEEP]));
PrintF("compact=%d ", static_cast<int>(scopes_[Scope::MC_COMPACT]));
PrintF("flushcode=%d ", static_cast<int>(scopes_[Scope::MC_FLUSH_CODE]));
PrintF("total_size_before=%d ", start_size_);
PrintF("total_size_after=%d ", Heap::SizeOfObjects());

View File

@ -1722,6 +1722,7 @@ class GCTracer BASE_EMBEDDED {
MC_MARK,
MC_SWEEP,
MC_COMPACT,
MC_FLUSH_CODE,
kNumberOfScopes
};

49
tools/gc-nvp-trace-processor.py Normal file → Executable file
View File

@ -47,8 +47,12 @@ def flatten(l):
def split_nvp(s):
t = {}
for m in re.finditer(r"(\w+)=(-?\d+)", s):
t[m.group(1)] = int(m.group(2))
for (name, value) in re.findall(r"(\w+)=([-\w]+)", s):
try:
t[name] = int(value)
except ValueError:
t[name] = value
return t
def parse_gc_trace(input):
@ -211,6 +215,9 @@ def plot_all(plots, trace, prefix):
def reclaimed_bytes(row):
return row['total_size_before'] - row['total_size_after']
def other_scope(r):
return r['pause'] - r['mark'] - r['sweep'] - r['compact'] - r['flushcode']
plots = [
[
Set('style fill solid 0.5 noborder'),
@ -219,9 +226,8 @@ plots = [
Plot(Item('Marking', 'mark', lc = 'purple'),
Item('Sweep', 'sweep', lc = 'blue'),
Item('Compaction', 'compact', lc = 'red'),
Item('Other',
lambda r: r['pause'] - r['mark'] - r['sweep'] - r['compact'],
lc = 'grey'))
Item('Flush Code', 'flushcode', lc = 'yellow'),
Item('Other', other_scope, lc = 'grey'))
],
[
Set('style histogram rowstacked'),
@ -256,19 +262,48 @@ plots = [
],
]
def calc_total(trace, field):
return reduce(lambda t,r: t + r[field], trace, 0)
def calc_max(trace, field):
return reduce(lambda t,r: max(t, r[field]), trace, 0)
def process_trace(filename):
trace = parse_gc_trace(filename)
total_gc = reduce(lambda t,r: t + r['pause'], trace, 0)
max_gc = reduce(lambda t,r: max(t, r['pause']), trace, 0)
total_gc = calc_total(trace, 'pause')
max_gc = calc_max(trace, 'pause')
avg_gc = total_gc / len(trace)
total_sweep = calc_total(trace, 'sweep')
max_sweep = calc_max(trace, 'sweep')
total_mark = calc_total(trace, 'mark')
max_mark = calc_max(trace, 'mark')
scavenges = filter(lambda r: r['gc'] == 's', trace)
total_scavenge = calc_total(scavenges, 'pause')
max_scavenge = calc_max(scavenges, 'pause')
avg_scavenge = total_scavenge / len(scavenges)
charts = plot_all(plots, trace, filename)
with open(filename + '.html', 'w') as out:
out.write('<html><body>')
out.write('<table><tr><td>')
out.write('Total in GC: <b>%d</b><br/>' % total_gc)
out.write('Max in GC: <b>%d</b><br/>' % max_gc)
out.write('Avg in GC: <b>%d</b><br/>' % avg_gc)
out.write('</td><td>')
out.write('Total in Scavenge: <b>%d</b><br/>' % total_scavenge)
out.write('Max in Scavenge: <b>%d</b><br/>' % max_scavenge)
out.write('Avg in Scavenge: <b>%d</b><br/>' % avg_scavenge)
out.write('</td><td>')
out.write('Total in Sweep: <b>%d</b><br/>' % total_sweep)
out.write('Max in Sweep: <b>%d</b><br/>' % max_sweep)
out.write('</td><td>')
out.write('Total in Mark: <b>%d</b><br/>' % total_mark)
out.write('Max in Mark: <b>%d</b><br/>' % max_mark)
out.write('</td></tr></table>')
for chart in charts:
out.write('<img src="%s">' % chart)
out.write('</body></html>')