Commit 47a293ed authored by Kevin Modzelewski's avatar Kevin Modzelewski

section ordering hack: use the PGO-determined ordering

Rather than do anything smart, just copy the ordering that the
pgo build used.  To keep the file reasonable, only emit
entries for functions that appear in the perf results (cuts from
>1M entries to ~2k).

I tried getting the hhvm "hfsort" to work, but ran into some
fixable-but-annoying issues getting it integrated (ex need to bring
in some other libraries).  Let's just try this for now; the goal
isn't to get the absolute best performance anyway, since for that
we'll use PGO and ignore the section ordering file.
parent 7c2b76ca
This source diff could not be displayed because it is too large. You can view the blob instead.
"""
This script attempts to generate a section_ordering.txt file
based on how gcc decided to lay out the pgo build.
"""
import subprocess
import sys
"""
typical usage:
make perf_combined
make pyston_pgo
python tools/generate_section_ordering_from_pgo_build.py pyston_pgo perf.data > section_ordering.txt
"""
if __name__ == "__main__":
assert len(sys.argv) == 3, "Usage: %s PGO_BINARY PERF_DATA" % sys.argv[0]
binary = sys.argv[1]
perf_data = sys.argv[2]
perf_results = subprocess.check_output(["perf", "report", "-i", perf_data, "--no-demangle", "-g",
"none", "--percent-limit", "0.0"])
functions_in_perf = set([])
for l in perf_results.split('\n'):
l = l.strip()
if not l:
continue
if not l[0].isdigit():
continue
func_name = l.rsplit(' ', 1)[1]
if func_name.startswith('0x0'):
continue
functions_in_perf.add(func_name)
print >>sys.stderr, "%d functions in the perf results" % len(functions_in_perf)
nm_output = subprocess.check_output(["nm", binary]).split('\n')
functions = []
for l in nm_output:
if not l:
continue
if not l[0].isalnum():
continue
addr, type, name = l.split()
if type not in 'tT':
continue
if name not in functions_in_perf:
continue
functions.append((int(addr, 16), name))
functions.sort()
for l in functions:
print ".text." + l[1]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment