The Daml Profiler allows you to to profile execution of your Daml code which can help spot bottlenecks and opportunities for optimization.Documentation Index
Fetch the complete documentation index at: https://docs.canton.network/llms.txt
Use this file to discover all available pages before exploring further.
Usage
To test this out, we use the skeleton project included in the assistant. We first create the project and build the DAR.profile-dir option. Sandbox will behave as usual but all profile results will be written to that directory. For this, we first create a configuration file that sets the profile-dir for Sandbox:
profile-results directory, we can see one JSON file per transaction produced by the script. Each file has a name of the form $timestamp-$command.json where $timestamp is the submission time of the transaction and $command is a human-readable description of the command that produced the transaction (for multi-command submissions, only the first one will be in the file name).
2021-03-17T12:32:17.361596Z-exercise:Asset:Give.json:
You can see the exercise as the root of the profile. Below that there are a few expressions to calculate signatories, observer and controllers and finally we see the create of the contract. In this simple example, nothing obvious stands out that we could do to optimize further. Speedscope provides a few other views that can be useful depending on your profile. Refer to the documentation for more information on that.![]()
Caveats
- The profiler currently does not take time into account that is spent outside of pure interpretation, e.g., time needed to fetch a contract from the database.
- The profiler operates on Daml-LF. This means that the identifiers used in the profiler correspond to Daml-LF expressions which includes autogenerated identifiers used by the compiler. E.g., in the example above,
Main:$csignatoryis the name of the function used to compute signatories ofAsset. You can view the Daml-LF code that the compiler generated usingdpm damlc inspect. This can be useful to see where an identifier is being used but it does take some experience to be able to read Daml-LF code with ease.
