EVM/Kernel: instrument the execution for benchmarking
Context
This MR is built on !10048 (closed), and adds the necessary instrumentation to benchmark the ticks per gas per opcodes. It adds two commits:
- Adds a module
benchmarks
inhandler.rs
that sends the specialwrite_debug
sections added by !10149 (merged). These are completely unsafe by design: we want to avoid as much as possible any overhead during the profiling, and usingdebug_msg!
(and especially the formatting) is consuming really too much. As the value to send to the profiler are always of the same size, the string is preallocated and modified in place right before usinghost.write_debug
directly. - Adds a feature flag
benchmark
for compilation, as such the benchmarking instrumentation has no impact for the real execution (and the ugly unsafe part is removed). It also adds the support of the variableEVM_KERNEL_FEATURES
in the Makefile to use features flags when compiling the kernel, for example:
make -f kernels.mk EVM_CONFIG=src/kernel_evm/config/benchmarking.yaml EVM_KERNEL_FEATURES=benchmark evm_unstripped_installer.wasm
Manually testing the MR
Run the kernel in the profiler compiled with the feature flag with any contract scenario: you should see the sections for each opcode.
Run the same scenario without the feature flag: you shouldn't see any section at all.
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rst
for the protocol and the environment,CHANGES.rst
at the root of the repository for everything else). -
Select suitable reviewers using the Reviewers
field below. -
Select as Assignee
the next person who should take action on that MR