filecoin-project / ref-fvm

Reference implementation of the Filecoin Virtual Machine
https://fvm.filecoin.io/
Other
376 stars 134 forks source link

Detailed execution gas profiling #696

Open magik6k opened 2 years ago

magik6k commented 2 years ago

It would be really useful to have some mechanism to get very detailed execution gas usage info.

This can be done by enabling debug symbols in wasmtime, adding a syscall which would log gas use with a backtrace, and having a mode in wasm-instrument which would invoke that syscall on each exec gas charge

Stebalien commented 2 years ago

This can be done by enabling debug symbols in wasmtime, adding a syscall which would log gas use with a backtrace, and having a mode in wasm-instrument which would invoke that syscall on each exec gas charge

We shouldn't need to add a new syscall. We already have a log syscall, we just need to extend it so it can take a file path/location. The logging subsystem already knows this information, even without backtracing. This will work even without debug symbols.

We already charge for WASM gas on every syscall, and, with #675, we'll record that charge in the execution trace.


Additionally, we should record every syscall and, optionally, the WASM backtrace in the execution trace. This also shouldn't require a new syscall.