Commit 1eb99619 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #574 from kmod/linkorder

Add a section-ordering script
parents c4c58d0d d8e5b7f6
......@@ -45,9 +45,11 @@ if(ENABLE_GOLD)
message(STATUS "found the gold linker ${GOLD_LINKER}")
set(CMAKE_LINKER "${GOLD_LINKER}")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -B${CMAKE_SOURCE_DIR}/tools/build_system")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--section-ordering-file,${CMAKE_CURRENT_SOURCE_DIR}/section_ordering.txt")
endif()
endif()
# pyston self host mode
if(ENABLE_SELF_HOST)
set(PYTHON_EXE "pyston")
......@@ -215,7 +217,11 @@ add_subdirectory(test/test_extension)
add_subdirectory(test/unittests)
add_subdirectory(tools)
add_executable(pyston $<TARGET_OBJECTS:PYSTON_MAIN_OBJECT> $<TARGET_OBJECTS:PYSTON_OBJECTS> $<TARGET_OBJECTS:FROM_CPYTHON>)
# There are supposed to be better ways [1] to add link dependencies, but none of them worked for me.
# [1] http://www.cmake.org/pipermail/cmake/2010-May/037206.html
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/linkdeps_dummy.c COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/linkdeps_dummy.c DEPENDS ${CMAKE_SOURCE_DIR}/section_ordering.txt)
add_executable(pyston $<TARGET_OBJECTS:PYSTON_MAIN_OBJECT> $<TARGET_OBJECTS:PYSTON_OBJECTS> $<TARGET_OBJECTS:FROM_CPYTHON> linkdeps_dummy.c)
# Wrap the stdlib in --whole-archive to force all the symbols to be included and eventually exported
target_link_libraries(pyston -Wl,--whole-archive stdlib -Wl,--no-whole-archive pthread m readline sqlite3 gmp ssl crypto unwind pypa liblz4 double-conversion ${LLVM_LIBS} ${LIBLZMA_LIBRARIES} ${OPTIONAL_LIBRARIES})
......
.text.div_i64_i64
.text.boxInt
.text.boxBool
.text._ZN6pyston2gc10SmallArena6_allocEmi
.text._ZNSt17_Function_handlerIFvPN6pyston2gc10SmallArena16ThreadBlockCacheEEZNS2_12freeUnmarkedERSt6vectorIPNS0_3BoxESaIS8_EEE3$_0E9_M_invokeERKSt9_Any_dataS4_
.text.memset
.text.gc_alloc
.text.gc_realloc
.text._ZN6pyston9BoxedList6ensureEi
.text.PyNumber_AsSsize_t
.text._ZN6pyston15objectNewNoArgsEPNS_10BoxedClassE
.text._PyIndex_Check
.text._ZN6pyston9threading21allowGLReadPreemptionEv
.text._ZN6pyston9getOpNameEi
.text._ZN6pyston8callFuncEPNS_17BoxedFunctionBaseEPNS_15CallRewriteArgsENS_11ArgPassSpecEPNS_3BoxES6_S6_PS6_PKSt6vectorIPKSsSaISA_EE
.text._ZN6pyston2gc9GCVisitor5visitEPv
.text.intLtInt
.text.intModInt
.text.intAddInt
.text.intMulInt
......@@ -106,6 +106,7 @@ This will typically look like:
Benchmark that was run. '--heap-map-target BENCHMARK' is
equivalent to '--heap-map-args ./pyston_release -i BENCHMARK'.
""".strip())
parser.add_argument("--perf-data", default="perf.data")
args = parser.parse_args()
func = args.func_name
......@@ -116,7 +117,7 @@ equivalent to '--heap-map-args ./pyston_release -i BENCHMARK'.
objdump = get_objdump(func)
p = subprocess.Popen(["perf", "annotate", "-v", func], stdout=subprocess.PIPE, stderr=open("/dev/null", "w"))
p = subprocess.Popen(["perf", "annotate", "-i", args.perf_data, "-v", func], stdout=subprocess.PIPE, stderr=open("/dev/null", "w"))
annotate = p.communicate()[0]
assert p.wait() == 0
......
......@@ -5,7 +5,7 @@ def tally(fn):
for l in open(fn):
samples = int(l.split()[3])
func = l.split()[-1]
func = l.rsplit(']', 1)[1].strip()
counts[func] = counts.get(func, 0) + samples
return counts
......@@ -23,11 +23,10 @@ def main():
diff_thresh = (total1 + total2) / 2 / 100
names.sort(key=lambda n: counts1.get(n, 0) + counts2.get(n, 0), reverse=True)
for n in names:
names.sort(key=lambda n: abs(counts1.get(n, 0) - counts2.get(n, 0)), reverse=True)
for n in names[:10]:
c1 = counts1.get(n, 0)
c2 = counts2.get(n, 0)
if abs(c1 - c2) >= diff_thresh:
print n, counts1.get(n, 0), counts2.get(n, 0)
if __name__ == "__main__":
......
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