Author: David Schneider <david.schnei...@picle.org> Branch: extradoc Changeset: r4374:438c3a9b7fce Date: 2012-07-26 16:31 +0200 http://bitbucket.org/pypy/extradoc/changeset/438c3a9b7fce/
Log: collect jit-summary data and extract the number of generated bridges for each benchmark diff --git a/talk/vmil2012/Makefile b/talk/vmil2012/Makefile --- a/talk/vmil2012/Makefile +++ b/talk/vmil2012/Makefile @@ -18,7 +18,7 @@ %.tex: %.py pygmentize -l python -o $@ $< -figures/%_table.tex: tool/build_tables.py logs/backend_summary.csv logs/summary.csv tool/table_template.tex +figures/%_table.tex: tool/build_tables.py logs/backend_summary.csv logs/summary.csv tool/table_template.tex logs/bridge_summary.csv tool/setup.sh paper_env/bin/python tool/build_tables.py $@ @@ -30,6 +30,10 @@ logs/backend_summary.csv: logs/logbench* tool/backenddata.py @if ls logs/logbench* &> /dev/null; then python tool/backenddata.py logs; fi +logs/bridge_summary.csv: logs/logbench* tool/bridgedata.py + @if ls logs/logbench* &> /dev/null; then python tool/bridgedata.py logs; fi + + logs:: tool/run_benchmarks.sh diff --git a/talk/vmil2012/tool/bridgedata.py b/talk/vmil2012/tool/bridgedata.py new file mode 100644 --- /dev/null +++ b/talk/vmil2012/tool/bridgedata.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +""" +Parse and summarize the jit-summary data """ + +import csv +import optparse +import os +import re +import sys +from pypy.jit.metainterp.history import ConstInt +from pypy.jit.tool.oparser import parse +from pypy.rpython.lltypesystem import llmemory, lltype +from pypy.tool import logparser + + +def collect_logfiles(path): + if not os.path.isdir(path): + logs = [os.path.basename(path)] + else: + logs = os.listdir(path) + all = [] + for log in logs: + parts = log.split(".") + if len(parts) != 3: + continue + l, exe, bench = parts + if l != "logbench": + continue + all.append((exe, bench, log)) + all.sort() + return all + + +def collect_data(dirname, logs): + for exe, name, log in logs: + path = os.path.join(dirname, log) + logfile = logparser.parse_log_file(path) + summary = logparser.extract_category(logfile, 'jit-summary') + if len(summary) == 0: + yield (exe, name, log, 'n/a', 'n/a') + summary = summary[0].splitlines() + for line in summary: + if line.startswith('Total # of bridges'): + bridges = line.split()[-1] + elif line.startswith('opt guards'): + guards = line.split()[-1] + yield (exe, name, log, guards, bridges) + + +def main(path): + logs = collect_logfiles(path) + if os.path.isdir(path): + dirname = path + else: + dirname = os.path.dirname(path) + results = collect_data(dirname, logs) + + with file("logs/bridge_summary.csv", "w") as f: + csv_writer = csv.writer(f) + row = ["exe", "bench", "guards", "bridges"] + csv_writer.writerow(row) + print row + for exe, bench, log, guards, bridges in results: + row = [exe, bench, guards, bridges] + csv_writer.writerow(row) + print row + +if __name__ == '__main__': + parser = optparse.OptionParser(usage="%prog logdir_or_file") + + options, args = parser.parse_args() + if len(args) != 1: + parser.print_help() + sys.exit(2) + else: + main(args[0]) diff --git a/talk/vmil2012/tool/build_tables.py b/talk/vmil2012/tool/build_tables.py --- a/talk/vmil2012/tool/build_tables.py +++ b/talk/vmil2012/tool/build_tables.py @@ -15,8 +15,12 @@ return [l for l in reader] -def build_ops_count_table(csvfile, texfile, template): - lines = getlines(csvfile) +def build_ops_count_table(csvfiles, texfile, template): + lines = getlines(csvfiles[0]) + bridge_lines = getlines(csvfiles[1]) + bridgedata = {} + for l in bridge_lines: + bridgedata[l['bench']] = l head = ['Benchmark', 'ops b/o', @@ -24,7 +28,8 @@ 'ops a/o', '\\% guards a/o', 'opt. rate in \\%', - 'guard opt. rate in \\%'] + 'guard opt. rate in \\%', + 'bridges'] table = [] # collect data @@ -42,14 +47,15 @@ "%.2f" % (guards_ao / ops_ao * 100,), "%.2f" % ((1 - ops_ao / ops_bo) * 100,), "%.2f" % ((1 - guards_ao / guards_bo) * 100,), + bridgedata[bench['bench']]['bridges'], ] table.append(res) output = render_table(template, head, sorted(table)) write_table(output, texfile) -def build_backend_count_table(csvfile, texfile, template): - lines = getlines(csvfile) +def build_backend_count_table(csvfiles, texfile, template): + lines = getlines(csvfiles[0]) head = ['Benchmark', 'Machine code size (kB)', @@ -85,9 +91,9 @@ tables = { 'benchmarks_table.tex': - ('summary.csv', build_ops_count_table), + (['summary.csv', 'bridge_summary.csv'], build_ops_count_table), 'backend_table.tex': - ('backend_summary.csv', build_backend_count_table) + (['backend_summary.csv'], build_backend_count_table) } @@ -96,10 +102,10 @@ if tablename not in tables: raise AssertionError('unsupported table') data, builder = tables[tablename] - csvfile = os.path.join('logs', data) + csvfiles = [os.path.join('logs', d) for d in data] texfile = os.path.join('figures', tablename) template = os.path.join('tool', 'table_template.tex') - builder(csvfile, texfile, template) + builder(csvfiles, texfile, template) if __name__ == '__main__': diff --git a/talk/vmil2012/tool/run_benchmarks.sh b/talk/vmil2012/tool/run_benchmarks.sh --- a/talk/vmil2012/tool/run_benchmarks.sh +++ b/talk/vmil2012/tool/run_benchmarks.sh @@ -9,7 +9,7 @@ pypy="${pypy_co}/pypy-c" pypy_opts=",--jit enable_opts=intbounds:rewrite:virtualize:string:pure:heap:ffi" baseline=$(which true) -logopts='jit-backend-dump,jit-backend-guard-size,jit-log-opt,jit-log-noopt' +logopts='jit-backend-dump,jit-backend-guard-size,jit-log-opt,jit-log-noopt,jit-summary' # checkout and build a pypy-c version if [ ! -d "${pypy_co}" ]; then echo "Cloning pypy repository to ${pypy_co}" _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit