Skip to main content

A tool to mep perf script events to classes of events using regex

Project description

perf-class

This program allows to group the CPU time spent in functions as outputed by perf script into classes. Eg. if your application spend 3% of time in "sort_down", 5% "sort_up", 4% "sort_final", and you give a map like "sort: Sorting", this tool will summarize those as "Sorting 12%".

This program is intended as a preprocessor to show where, roughly, a CPU spend its time in various application. The result such as "Sorting : 12%, Computing : 23%" can be given to a pie chart, typically.

The map file, to describe the mapping, is simply a series of "regex : class", one by line. Each symbol will be matched against the regex, and upon match will be considered of the given class. The tool will start with the top of the stack trace, and if no match is found, re-try with the previous function in the stack, etc. This is needed, and explain why a simple script was not sufficient to achieve the purpose of this script as a lot of time spend in the kernel is in "raw_spin_lock" functions. Only the calling functions of those generic hit points will allow to find the reason of the time spent there, and therefore allow a mapping to the class.

Installation

This package can be installed with pip, for instance:

pip3 --user install perf-class

Example

A result of perf script is providden in the "samples" folder, as well as a sample mapping file.

perf-class samples/perf.script --map samples/kernel.map --no-output-failed --min 0.1

Will map all symbols exported using "perf record -a -g ... | perf script" in samples/perf.script using the mapping in samples/kernel.map as follow:

Finished, matched 98.840972% of cycles
IO 82.277282
Routing 9.182298
Filtering 5.843719
Kernel 1.532659

The firstline is written to stderr, so one may pipe stdout of this program safely to recover the file, and use it to plot some nice graphs of how your system reduce some time spent in a group of functions.

Without the last two options, one would get :

Finished, matched 98.840972% of cycles
IO 83.242081
Routing 9.289971
Filtering 5.912243
Kernel 1.550632
native_write_msr 0.147001
__switch_to 0.105550
hrtimer_start_range_ns 0.065908
entry_SYSCALL_64_after_hwframe 0.065326
smpboot_thread_fn 0.050715
__nanosleep 0.050668
do_nanosleep 0.045614
sys_nanosleep 0.045609
worker_thread 0.035491
do_syscall_64 0.035475
timerqueue_add 0.035317
syscall_return_via_sysret 0.030425
nanosleep@plt 0.030420
entry_SYSCALL_64 0.030417
kthread_should_stop 0.030415
ReloadConfigThread 0.030098
hrtimer_nanosleep 0.025339
_copy_from_user 0.020287
clockevents_program_event 0.020284
process_one_work 0.020282
__switch_to_asm 0.020260
get_nohz_timer_target 0.015214
__hrtimer_init 0.015213
copy_user_generic_unrolled 0.015210
__pthread_disable_asynccancel 0.015200
tick_program_event 0.015194
get_timespec64 0.014544
ktime_get 0.010146
_raw_spin_unlock_irqrestore 0.010140
schedule 0.010137
enqueue_hrtimer 0.010134
rb_insert_color 0.010134
mwait_idle 0.009315
kthread_should_park 0.005075
put_pwq 0.005074
ksoftirqd_should_run 0.005074
igb_rd32 0.005074
User_IO 0.005074
__pthread_enable_asynccancel 0.005073
_raw_spin_lock_irqsave 0.005073
_cond_resched 0.005073
hrtimer_active 0.005073
__indirect_thunk_start 0.005072
hrtimer_try_to_cancel 0.005071
native_load_tls 0.005071
ret_from_intr 0.005071
read_tsc 0.005070
rcu_all_qs 0.005068
__softirqentry_text_start 0.005063
lapic_next_deadline 0.005061

See perf-class --help for other options

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

perf-class-1.0.5.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

perf_class-1.0.5-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file perf-class-1.0.5.tar.gz.

File metadata

  • Download URL: perf-class-1.0.5.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for perf-class-1.0.5.tar.gz
Algorithm Hash digest
SHA256 41cf5cad29bc904538d69416f3538c78a85720504898005aa9ae5f46fd059aa1
MD5 c36790e7eebe79a6599e3bc9f20e21c5
BLAKE2b-256 d026e03497107a090a1c71bf0cdedb8447dbd918f4b6929343d9b07e42b34106

See more details on using hashes here.

File details

Details for the file perf_class-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: perf_class-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for perf_class-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 17ac0975c06813b79a9ec55aab16bec15d3362e106a4da092de99d6774b47f53
MD5 ef4e0b2bde65b1a722d4a52b5e5492d6
BLAKE2b-256 cd098b9d41a0d6b762dbe4e85c64773e2bb2bbbd3e06003b73edc815ccc00325

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page