Skip to content

Profiling Birch programs

Lawrence Murray edited this page Feb 19, 2021 · 1 revision

You may be interested in profiling your Birch programs to identify focal points for performance tuning. This page provides some options.

Gperftools

On most platforms you can use gperftools. This is widely available in package managers, for example:

System Command
Ubuntu apt install google-perftools
openSUSE zypper install gperftools
macOS brew install gperftools

When running birch, set some additional environment variables just before the call to enable profiling:

LD_PRELOAD=/usr/lib/libprofiler.so CPUPROFILE=birch.prof CPUPROFILE_FREQUENCY=1000 birch sample config/config.json

Check that the path in LD_PRELOAD is correct for your system. It may instead be something else, such as /usr/lib64/libprofiler.so (e.g. on openSUSE 64-bit). On macOS LD_PRELOAD is replaced with DYLD_INSERT_LIBRARIES:

DYLD_INSERT_LIBRARIES=/usr/local/lib/libprofiler.dylib CPUPROFILE=birch.prof CPUPROFILE_FREQUENCY=1000 birch sample config/config.json

Once the job has completed, build a PDF report with:

prof --pdf birch birch.prof > birch.pdf

and inspect birch.pdf, or a text report with:

prof --text birch birch.prof > birch.txt

and inspect birch.txt

Instruments

On macOS, the Time Profiler tool in Xcode provides similar reports to gperftools, but with a nicer interface for exploring the results.

To use it, open Xcode, select the menu item Xcode > Open Developer Tool > Instruments then the icon Time Profiler. Start running birch in a terminal then click the All Processes button at the top of the Time Profiler window and select the birch process. Click the record button to start recording the running process. The results will appear in the window automatically.

Other options