Flamegraphs for solidity that help to spot optimisation opportunities!
When we have some solidity code in place and want to optimize the code, currently there are limited tools to help with that. There is no open-source solidity profiler that is actively maintained and works with foundry or hardhat. This makes the gas optimization process time-consuming and of course, it requires a lot of skills.
Because of these reasons only experienced solidity developers are good at gas optimization since they are better at guessing and drilling which part causes more gas. This project enables more developers to save their engineering hours while being better at gas optimizations using flamegraphs!
Flamegraphs are used to profile system software and find performance bottlenecks. In the X axis, we have the functions that are executing serially, while on the y axis, we have functions that are invoking other functions hereby creating a call stack.
We have built a foundry plugin that parses the low-level debug trace to generate a folded stack trace for generating a flamegraph.
We have written this project in Rust using the open-source foundry crates. However, we found that the solidity's source mappings are very buggy and do not resolve to the appropriate solidity code. Hence to offset that we are also looking at nearby steps to get more hints. However, even that works only up to some extent. For generating the flamegraphs we have used inferno library that generates svgs.