-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Support for Flamegraph #8315
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some things I'd like to highlight
arena: &CallTraceArena, | ||
decoder: &CallTraceDecoder, | ||
) -> Result<String, std::fmt::Error> { | ||
) -> Result<(String, Vec<String>), std::fmt::Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am adding the logic in this module itself to prevent code duplication, since logic for the folded stack trace is minimal here. Maybe the function render_trace_arena
be renamed or some refactoring to be done to have this logic be used for both purposes: generating console printable traces and folded stack traces for flamegraph.
let mut folded_stack_lines = render_trace_arena(arena, decoder).await?.1; | ||
folded_stack_lines.reverse(); | ||
|
||
let file_name = "flamegraph.svg"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is placing the svg in the project root. This can be moved to a subdirectory / filename. Any preferences?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can open it right away? flamegraph-rs is using opener
in their CLI interface:
https://github.com/flamegraph-rs/flamegraph/blob/50611df2c9ee541c53689dda3d5164019cd778e8/src/lib.rs#L459
https://crates.io/crates/opener
let writer = std::fs::File::create(file_name).unwrap(); | ||
|
||
let mut options = inferno::flamegraph::Options::default(); | ||
options.flame_chart = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inferno crate provides some options. Some of them could be passed on to user like choosing between flamegraph and flamechart.
Just realised that adding these flags on the test subcommand is not a good idea. Separate subcommand like forge flamegraph
makes more sense? (I did this in test subcommand to prevent code duplication)
hey @zemse mind setting base branch to #8222? should be easier to review after that also trace printing logic will change after #8224 and |
oh huh, I guess because #8222's branch was deleted, this was too. Didn't know that's how it worked, sorry about that |
Motivation
This PR closes #776 and builds on top of #8222.
Solution
The current implementation modifies existing logic in test subcommand and evm/traces crate.
It adds a
flamegraph
flag to the test subcommand. The interface is similar to thedebug
flag. A pattern is to be provided to theflamegraph
flag and additionalmatch-contract
ormatch-path
maybe used. Finally it is required that just a single test case must be run.Example:
This will execute the
test_hash_1_a_sol
test and generate aflamegraph.svg
file in the project root.