Profiling Unison programs

There are two new commands for profiling Unison programs.

  • run.profiled will run the program just like run, but will display abbreviated profiling information at the end. It looks for the hottest spots in the program and shows just enough of a tree to display those hot spots.
    • run.profiled.full is like the above, but takes a file name to write the complete profile to. There are two modes this can run in, based on the file name.
      • If the file name ends in .ticks, then a file suitable for use with flamegraph.pl will be produced. This can be used to visualize the profile.
      • Other suffixes, like .prof will just produce textual output, containing a table of identified hot spots, and a full tree of the recorded profile information.

For instance, in the @dolio/profile-example project, executing

@dolio/profile-example/main> run.profiled doStuff

will produce output like

A snapshot of the UCM command line profiler output

while,

@dolio/profile-example/main> run.profiled.full doStuff stuff.prof

will result in a stuff.prof file that looks like:

A snapshot of the full profiling output

The "Hot Spots" table shows the total direct cost attributed to each function listed. The "Costs" tree displays how functions call one another, so a single function may occur multiple times, nested in different places. The "Local" column displays the direct cost attributed to that function, while the "Inherited" column shows the overall cost of the function and all its children in the tree.

Instead, executing

@dolio/profile-example/main> run.profiled.full doStuff stuff.ticks

produces a less readable file, but running flamegraph on it with

$ flamegraph.pl stuff.ticks > profiler-output.svg

produces an image like

A snapshot of a flamegraph generated from Unison profiling output

which displays similar information to the "Costs" tree above.