History

perf script: Autopep8 futex-contention

10 years leaves its mark! Python has evolved and so has its style guide. Even with vim it is getting hard to follow the no longer valid guidelines (spaces vs. tabs). Autopep8 this code to modernize it!

Hagen Paul Pfeifer committed 6 years ago

Commit 2a684fc1 parent 002a3d61 file · +28 −23Browse files

Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all

Unified · Split

tools/perf/scripts/python/futex-contention.py+28−23
@@ -12,41 +12,46 @@ · 11 unmodified lines
1212
1313 from __future__ import print_function
1414
15−import os, sys
16−sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
15+import os
16+import sys
17+sys.path.append(os.environ['PERF_EXEC_PATH'] +
18+ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
1719 from Util import *
1820
1921 process_names = {}
2022 thread_thislock = {}
2123 thread_blocktime = {}
2224
23−lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time
24−process_names = {} # long-lived pid-to-execname mapping
25+lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time
26+process_names = {} # long-lived pid-to-execname mapping
27+
2528
2629 def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, callchain,
27− nr, uaddr, op, val, utime, uaddr2, val3):
28− cmd = op & FUTEX_CMD_MASK
29− if cmd != FUTEX_WAIT:
30− return # we don't care about originators of WAKE events
30+ nr, uaddr, op, val, utime, uaddr2, val3):
31+ cmd = op & FUTEX_CMD_MASK
32+ if cmd != FUTEX_WAIT:
33+ return # we don't care about originators of WAKE events
34+
35+ process_names[tid] = comm
36+ thread_thislock[tid] = uaddr
37+ thread_blocktime[tid] = nsecs(s, ns)
3138
32− process_names[tid] = comm
33− thread_thislock[tid] = uaddr
34− thread_blocktime[tid] = nsecs(s, ns)
3539
3640 def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, callchain,
37− nr, ret):
38− if tid in thread_blocktime:
39− elapsed = nsecs(s, ns) - thread_blocktime[tid]
40− add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed)
41− del thread_blocktime[tid]
42− del thread_thislock[tid]
41+ nr, ret):
42+ if tid in thread_blocktime:
43+ elapsed = nsecs(s, ns) - thread_blocktime[tid]
44+ add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed)
45+ del thread_blocktime[tid]
46+ del thread_thislock[tid]
47+
4348
4449 def trace_begin():
45− print("Press control+C to stop and show the summary")
50+ print("Press control+C to stop and show the summary")
4651
47−def trace_end():
48− for (tid, lock) in lock_waits:
49− min, max, avg, count = lock_waits[tid, lock]
50− print("%s[%d] lock %x contended %d times, %d avg ns" %
51− (process_names[tid], tid, lock, count, avg))
5252
53+def trace_end():
54+ for (tid, lock) in lock_waits:
55+ min, max, avg, count = lock_waits[tid, lock]
56+ print("%s[%d] lock %x contended %d times, %d avg ns" %
57+ (process_names[tid], tid, lock, count, avg))