Skip to content
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

Histogram tracer #323

Merged
merged 5 commits into from
May 21, 2021
Merged

Histogram tracer #323

merged 5 commits into from
May 21, 2021

Conversation

chfast
Copy link
Member

@chfast chfast commented May 13, 2021

No description provided.

@chfast chfast requested review from axic, gumb0 and jwasinger May 13, 2021 19:38
@codecov
Copy link

codecov bot commented May 13, 2021

Codecov Report

Merging #323 (dd907fe) into master (2c1f473) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head dd907fe differs from pull request most recent head 174cc7e. Consider uploading reports for the commit 174cc7e to get more accurate results

@@           Coverage Diff           @@
##           master     #323   +/-   ##
=======================================
  Coverage   99.77%   99.77%           
=======================================
  Files          27       28    +1     
  Lines        3932     3954   +22     
=======================================
+ Hits         3923     3945   +22     
  Misses          9        9           
Flag Coverage Δ
consensus 95.29% <24.32%> (-2.44%) ⬇️
unittests 99.77% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/evmone/tracing.hpp 100.00% <ø> (ø)
lib/evmone/tracing.cpp 100.00% <100.00%> (ø)
lib/evmone/vm.cpp 100.00% <100.00%> (ø)
test/unittests/tracing_test.cpp 100.00% <100.00%> (ø)
lib/evmone/execution_state.hpp 100.00% <0.00%> (ø)
test/unittests/execution_state_test.cpp 100.00% <0.00%> (ø)


trace_stream << '\n';
EXPECT_EQ(trace(add(0, 0)), R"(
--- # HISTOGRAM depth=0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this valid in CSV?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. But this is yaml document start mark.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CSV can only have optional header line with column names. You cannot have any title line.

The fancier YAML wrapper would be

--- # HISTOGRAM
depth: 0
csv: |
  opcode,count
  ADD,1
  PUSH1,2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why not output YAML and then whoever wants CSV can do the conversion themselves (or in worst-case by skipping the top 3 lines) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because nobody wants YAML. I used --- because of no better ideas.

};
} // namespace

std::unique_ptr<Tracer> create_histogram_tracer(std::ostream& out)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would add a comment (or on the class) explaining what this does, i.e. outputs a histogram of opcodes in a CSV format.

m_out << "--- # HISTOGRAM depth=" << m_depth << "\nopcode,count\n";
for (size_t i = 0; i < std::size(m_counts); ++i)
{
if (m_counts[i] != 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have thre options?

  • do not print zeroes
  • one which also prints all the zero opcodes
  • only those zero opcodes which are defined for the evm version

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these options make sense, but I don't think it is worth doing these right now.

@axic
Copy link
Member

axic commented May 13, 2021

There's missing coverage on the histogram evmc option.

@chfast chfast force-pushed the histogram_tracer branch 4 times, most recently from cb6d698 to 78a8475 Compare May 14, 2021 12:05
}
}

m_code = nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe zero out m_counts and m_depth then, too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well... because we have only single table in tracer we cannot measure internal calls separately. Therefore we should output only at depth=0 (and only then zeroing counters make sense). Moreover, reporting depth is useless.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, is on_execution_start called for each subcall? It changes m_code, how would it work after return from subcall then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shit, it was suppose to be easy tracer example...

lib/evmone/tracing.cpp Outdated Show resolved Hide resolved
@chfast chfast merged commit 0aba799 into master May 21, 2021
@chfast chfast deleted the histogram_tracer branch May 21, 2021 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants