Use psrecord and Plotly.js to profile a Mantid workflow.
It monitors CPU and RAM usage, and reports the time span of each algorithm (currently, only algorithms are recorded).
To profile the SNSPowderReduction.py
workflow:
python SNSPowderReduction.py & python path/to/mantid-profiler/mantid-profiler.py $!
The script attaches to the last spawned process, so you can also use the profiler if you are working with MantidPlot
:
./MantidPlot & python path/to/mantid-profiler/mantid-profiler.py $!
psutil
- You need to build Mantid with the
-DPROFILE_ALGORITHM_LINUX=ON
CMake
flag to get the timing output from the algorithms.
After running on the SNSPowderReduction.py
workflow, the profiler produces a profile.html
file to be viewed with an internet browser.
You can interact with a demo profile here.
Controls:
- Mouse wheel to zoom (horizontal zoom only)
- Left click to select zoom region (horizontal zoom only)
- Double-click to reset axes
- Hold shift and mouse click to pan
--outfile
: (type=str
) Specify the name of the output profile. Default isprofile.html
.--infile
: (type=str
) Specify the name of input file containing algorithm timings. Default isalgotimeregister.out
.--logfile
: (type=str
) Choose a name for output file containing process monitor data generated bypsrecord
. Default ismantidprofile.txt
.--interval
: (type=float
) How long to wait between each sample (in seconds) for CPU and RAM monitoring. By default the process is sampled as often as possible.--mintime
: (type=float
) Minimum duration of an algorithm for it to appear in the profiling graph (in seconds). Default is 0.1s.
viztracer creates similar information for generic python software
Neil Vaytet, European Spallation Source