ethereum / evmone

Fast Ethereum Virtual Machine implementation
Apache License 2.0
865 stars 287 forks source link

evmmax: Make ModArith header-only and constexpr #964

Closed rodiazet closed 3 months ago

rodiazet commented 4 months ago

Move all ModArith's methods to the class definition and make them constexpr.

Change evmmax library type to INTERFACE.

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 97.95918% with 1 line in your changes missing coverage. Please review.

Project coverage is 94.29%. Comparing base (391bd64) to head (81d067e).

Files Patch % Lines
test/unittests/evmmax_test.cpp 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #964 +/- ## ========================================== - Coverage 94.29% 94.29% -0.01% ========================================== Files 143 143 Lines 16128 16131 +3 ========================================== + Hits 15208 15210 +2 - Misses 920 921 +1 ``` | [Flag](https://app.codecov.io/gh/ethereum/evmone/pull/964/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum) | Coverage Δ | | |---|---|---| | [eof_execution_spec_tests](https://app.codecov.io/gh/ethereum/evmone/pull/964/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum) | `16.64% <0.00%> (-0.23%)` | :arrow_down: | | [ethereum_tests](https://app.codecov.io/gh/ethereum/evmone/pull/964/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum) | `26.93% <97.95%> (+<0.01%)` | :arrow_up: | | [ethereum_tests_silkpre](https://app.codecov.io/gh/ethereum/evmone/pull/964/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum) | `18.69% <100.00%> (+<0.01%)` | :arrow_up: | | [execution_spec_tests](https://app.codecov.io/gh/ethereum/evmone/pull/964/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum) | `17.73% <0.00%> (-0.23%)` | :arrow_down: | | [unittests](https://app.codecov.io/gh/ethereum/evmone/pull/964/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum) | `89.72% <97.95%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/ethereum/evmone/pull/964?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum) | Coverage Δ | | |---|---|---| | [include/evmmax/evmmax.hpp](https://app.codecov.io/gh/ethereum/evmone/pull/964?src=pr&el=tree&filepath=include%2Fevmmax%2Fevmmax.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum#diff-aW5jbHVkZS9ldm1tYXgvZXZtbWF4LmhwcA==) | `100.00% <100.00%> (ø)` | | | [lib/evmone\_precompiles/bn254.cpp](https://app.codecov.io/gh/ethereum/evmone/pull/964?src=pr&el=tree&filepath=lib%2Fevmone_precompiles%2Fbn254.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum#diff-bGliL2V2bW9uZV9wcmVjb21waWxlcy9ibjI1NC5jcHA=) | `100.00% <ø> (ø)` | | | [lib/evmone\_precompiles/secp256k1.cpp](https://app.codecov.io/gh/ethereum/evmone/pull/964?src=pr&el=tree&filepath=lib%2Fevmone_precompiles%2Fsecp256k1.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum#diff-bGliL2V2bW9uZV9wcmVjb21waWxlcy9zZWNwMjU2azEuY3Bw) | `100.00% <ø> (ø)` | | | [test/unittests/evmmax\_test.cpp](https://app.codecov.io/gh/ethereum/evmone/pull/964?src=pr&el=tree&filepath=test%2Funittests%2Fevmmax_test.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ethereum#diff-dGVzdC91bml0dGVzdHMvZXZtbWF4X3Rlc3QuY3Bw) | `96.55% <0.00%> (-1.70%)` | :arrow_down: |
chfast commented 3 months ago

These are the rough performance improvements:

precompile<PrecompileId::ecrecover, evmmax_cpp>_mean                       -0.0445         -0.0445        409414        391193        409365        391152
precompile<PrecompileId::ecadd, evmmax_cpp>_mean                           -0.0008         -0.0007          9156          9148          9153          9147
precompile<PrecompileId::ecmul, evmmax_cpp>_mean                           -0.0639         -0.0636        190056        177917        189981        177891