OProfile Yet Another Linux Preformance-Profiling Tool
Yipeng Wang, Washington University in St. Louis Outline
● Introduction ● Features ● Tools ● Examples ● References ● Demo Introduction
● A relatively old tool: John Levon developed OProfile in 2001 for Linux kernel 2.4. ● A statistical profiler (No need to instrument code!) ● Before Version 0.9.7: Utilizes a kernel driver and a daemon to collect sample data; After Verion 0.9.8: uses the Linux Kernel Performance Event Subsystem in Linux 2.6.31 for sampling. Features
● Unobtrusive ● System-wide profiling ● Single process profiling ● Event counting ● Performance counter support ● Call-graph support ● Low overhead ● Post-profile analysis ● System support Common Tools
● ophelp ○ This utility lists the available events and short descriptions. ● operf ○ This is the program for collecting profile data. ● ocount ○ This tool is used for simple event counting. Common Tools
● opreport ○ This is the main tool for retrieving useful profile data. ● opannotate ○ This utility can be used to produce annotated source, assembly or mixed source/assembly. Source level annotation is available only if the application was compiled with debugging symbols. ● opgrof ○ This utility can output gprof-style data files for a binary, for use with gprof -p. Install
● Requires root access ● Get the latest version from OProfile website ● In terminal, run the # ./Configure & make & make install ● Note: to work with Java applications, --with-java flag needs to be added, and JDK path needs to be specified. ● Operf - Profiling a single program
# operf [target_program] [args] Operf - Profiling a single program
# opreport Example: profiling Wget
# operf wget https://wordpress.org/latest.tar.gz
# opreport
Showing symbols Operf - System-wide profiling
# operf --system-wide Operf - System-wide profiling
# operf --system-wide Demo: Cache Optimization Without Padding Add Padding to Data Structure Add Padding to Data Structure Questions? References:
OProfile Websites:
https://oprofile.sourceforge.io/about/
https://oprofile.sourceforge.io/examples/
OProfile Tutorial:
https://linuxhint.com/oprofile-tutorial/