-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Support for Flamegraph #8640
Support for Flamegraph #8640
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.
Thank you for this! Left several comments
Wondering if --flamegraph
should automatically enable --decode-internal
? I think it doesn't hurt but would make flamegraphs more informative by default
It seems that current folded stack trace impl is a bit incorrect. Not yet sure what's the issue, but for me the flamegraph for the following test does not look correct:
contract Contract {
uint256 number;
function run() public {
for (uint i = 0; i < 10; i++) {
number += 1;
}
}
}
contract TestContract {
function test() public {
Contract c = new Contract();
c.run();
}
}
Sorry for the delay. Thanks for the review! I have made the changes and rebased the branch. Please re-review. |
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.
lgtm, tested locally and flamegraphs are looking good, UX is smooth too!
let's merge FoldedStackTraceBuilder
into signle file as it's not that large, and would also appreciate some docs on what it's doing (especially on the struct contents and how those are manipulated)
Thanks for checking it out! I've resolved the review comments, added some comments, and rebased the branch. |
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.
overall lgtm, have a question re merging of entires:
let mut trace = super::FoldedStackTraceBuilder::default();
trace.enter("top".to_string(), 500);
trace.enter("child_a".to_string(), 100);
trace.exit();
trace.enter("child_a".to_string(), 200);
trace.exit();
assert_eq!(
trace.build_without_subtraction(),
vec![
"top 500", //
"top;child_a 100",
"top;child_a 200",
]
);
shouldn't child_a
entries end up merged here?
Always found that the forge test invariants::VaultTest::testDepositTokens --flamegraph This way, the options to select tests would not be mutually exclusive. |
Congrats on this btw!!! |
bump revm-inspectors
@klkvr Currently, I was generating a flamechart instead. When it's flamegraph then the inferno lib sorts the lines to render with merged functions. @iFrostizz thanks for feedback, it makes sense to use general tests matching logic. I have changed the # sorts functions by name and merges them
forge test --match-test test_hash_var_len_2 --flamegraph
# does not merge functions and prints them in execution order, basically visualizes the trace chart
forge test --match-test test_hash_var_len_2 --flamechart Please try and would love feedback! |
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.
LGTM, works great for me locally!
left a couple small comments, should be quick fixes
Note: profiling gas is a bit different vs traditional stack sampling, so there are some bugs I'm observing rn which we can look into in follow-ups. Mostly its related to refunds which result in negative cost code paths or children spending more gas than parents |
Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com>
Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com>
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.
ty!
pending dep nits
I cloned the PR and ran it against Solady, but something seems to not be matching? https://github.com/Vectorized/solady
when there's clearly such a test
which the normal matcher hits
|
@gakonst this should be
|
I've updated the PR description to reflect the current code. Sorry for the inconvenience. |
Motivation
This PR closes #776. Old PR #8315.
Solution
Adds a
flamegraph
andflamechart
flag to the test subcommand. Using--match-test
and/or--match-contract
just a single test case must be run.Example:
This will execute just the
test_hash_1_a_sol
test and generate aflamegraph.svg
file incache
dir and will also try to open this file in the default program.