Skip to content

Commit

Permalink
tested :perf-jit:1 for python profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
aayasin committed Dec 31, 2024
1 parent b402edd commit 0474b05
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ test-pmu-tools: do.py pmu.py

PT=perf-tools.1
clean:
rm -rf {run,BC,datadep,$(AP),openssl,CLTRAMP3D[.\-]}*{csv,data,old,log,txt} \
rm -rf {$(AP),`echo $(AP_MT)|sed 's/ /-/g'`,CLTRAMP3D[.\-],BC,datadep,openssl,pagefault,permute,run}*{csv,data,old,log,txt,json,.tar.gz} \
$(PT) run-mem-bw* setup-system-* test-{default-track-perf,dir,mem-bw,srcline,stats,study} .CLTRAMP3D*cmd .ipc_*.txt
rm -f .prepush_state.cmd
post-push:
Expand Down
10 changes: 7 additions & 3 deletions do.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
__author__ = 'ayasin'
# pump version for changes with collection/report impact: by .01 on fix/tunable,
# by .1 on new command/profile-step/report/flag or TMA revision
__version__ = 3.98
__version__ = 3.99

import argparse, os.path, re, sys
import analyze, common as C, pmu, stats, tma
Expand Down Expand Up @@ -402,7 +402,7 @@ def version(tool): C.fappend('%s: %s' % (tool, exe_1line('%s --version | head -1
def perf_version(): return exe_1line(args.perf + ' --version', heavy=False).replace('perf version ', '')
def perf_newer_than(to_check):
ver = perf_version()
if ver.count('.') == 2: ver = '.'.join(ver.split('.')[:2])
if ver.count('.') > 1: ver = '.'.join(ver.split('.')[:2])
if not ver.replace('.', '').isdigit():
C.warn('unrecognized perf version: %s' % ver)
return None
Expand Down Expand Up @@ -453,7 +453,7 @@ def profile_exe(cmd, msg, step, mode='redirect', tune='', fail=0):
if args.sys_wide and not (' -a ' in cmd): C.error("Incorrect system wide in profile-step='%s' cmd='%s'" % (msg, cmd))
if mode == 'perf-stat': return exe1(prepend_PERF(cmd), msg, fail=fail)
else:
if 'perf record' in cmd and do['perf-jit']: assert ' -k1' in cmd, "JIT profiling: incorrect flags for perf-record"
if 'perf record' in cmd and do['perf-jit'] == 1 and ' -k1' not in cmd: error("JIT profiling: incorrect flags for perf-record")
return exe(cmd, msg)
def profile_mask_help(filename = 'profile-mask-help.md'):
hdr = ('%7s' % 'mask', '%-50s' % 'profile-step', 'additional [optional] arguments')
Expand Down Expand Up @@ -591,6 +591,9 @@ def peek_stdout(what, stop):
x = "ps -ef | grep java | grep -v 'grep java|hack record' | grep '\-XX:+PreserveFramePointer' | grep '\-agentpath'"
elif do['perf-jit'] == 2:
x = "%s -m sysconfig | grep -F no-omit-frame-pointer | grep -F no-omit-leaf-frame-pointer" % do['python']
if exe(x, fail=0): C.error('Improper python for profiling; did you set :python tunable?')
# this check must be done after app is started (JIT python isn't limited to system-wide)
x = "true" #"ps -ef | grep python | grep -vE 'grep.*python' | tail -1 | grep '\-X perf'"
else: assert 0, 'unsupported perf-jit mode'
if exe(x, fail=0): C.error('JIT-profiling was not launched properly')
if en(1):
Expand Down Expand Up @@ -1208,6 +1211,7 @@ def main():
do['perf-common'] += ' -C %s' % args.cpu
if not do['comm']: do['perf-filter'] = 0
if do['perf-jit']:
# TODO: turn :perf-jit into a mask so that workloads using both Java & Python may be profiled, Django e.g.
if do['perf-jit'] == 1:
assert args.sys_wide > 0, "system-wide profiling is required for JIT profiling"
if profiling(): C.info("JIT profiling for Java; make sure JVM was started with '-XX:+PreserveFramePointer -agentpath:%s'" % find_jvmti())
Expand Down
2 changes: 1 addition & 1 deletion lbr/lbr.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ def print_all(nloops=10, loop_ipc=0):
# print functions
if not loop_ipc:
funcs_list = sorted(funcs.funcs, reverse=True)
nfuncs = min(len(funcs_list), 10)
nfuncs = min(len(funcs_list), C.env2int('LBR_FUNCS', 10))
if nfuncs:
if os.getenv("LBR_FUNCS_LOG"):
log = open(os.getenv("LBR_FUNCS_LOG"), 'w')
Expand Down

0 comments on commit 0474b05

Please sign in to comment.