This is a collection of scripts to profile the Move VM and the Aptos VM using Valgrind, which allows us to tell how many machine instructions a Move instruction or a certain VM procedure costs.
The scripts were originally developed for calibrating gas costs, but could also be used to understand the performance characteristics of the VM in general.
To run the scripts, simply invoke the main binary via cargo run -p aptos-vm-profiling
.
The main binary will compile the individual scripts in release mode and then profile them.
Each profiling pass will produce two outputs:
foo.log
foo.txt
The log file is the raw output of Valgrind, which is not generally human-readable but to be fed into other programs. The text file is the source code annotated with the instruction costs, generated by callgrind-annotate, which is the one you should look into.
Valgrind seems to have trouble attributing the costs of inline functions to the callers. This is also the reason why the scripts are compiled using the release profile rather than performance, which has LTO enabled that would make it even harder to analyze the costs.