Profiling
Profile simulations with Linux perf and view the call-graph in
hotspot. Uses the profile build mode (binary suffix
_profile, typically with frame pointers enabled).
Upstream reference: https://github.com/omnetpp/opp_repl/blob/main/doc/profiling.md
Python API
# Build + run + open hotspot
open_profile_report(simulation_project=inet_project,
working_directory_filter="examples/ethernet",
config_filter="General",
run_number=0,
sim_time_limit="10s")
# Build + run, return the perf.data path
f = generate_profile_report(simulation_project=inet_project,
working_directory_filter="examples/ethernet",
config_filter="General",
run_number=0,
sim_time_limit="10s")
Both wrap perf record -g --call-graph dwarf and write
perf.data into the simulation's working directory. Override the
filename with output_file=.
Requirements
Linux with
perfenabled and accessible.perf_event_paranoidmay need to be relaxed:sudo sysctl -w kernel.perf_event_paranoid=1Hotspot (
hotspotpackage or AppImage) on PATH foropen_profile_report().
Reading the report
- Bottom-up view in Hotspot shows the hottest functions.
- Flame graph (via Hotspot or
perf script | stackcollapse-perf.pl) reveals call stacks. - For OMNeT++ sims, expect most time in
cMessagedispatch, RNG, and your C++ modules.
Pitfalls
perf record -g --call-graph dwarfneeds DWARF debug info — always build with-gon top of-O2.- Without frame pointers and with LTO, stacks may be truncated.
Add
-fno-omit-frame-pointerto theprofilemode's CXXFLAGS. - Profiling on a loaded machine is noisy; pin to one CPU with
taskset -c 0when possible.
See also
opp-repl-speed-tests— regression dashboard for wall/cpu time.opp-repl-running-simulations— selecting the single task to profile.