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

Upgrade intx to 0.6.0 #345

Merged
merged 3 commits into from
Jun 28, 2021
Merged

Upgrade intx to 0.6.0 #345

merged 3 commits into from
Jun 28, 2021

Conversation

chfast
Copy link
Member

@chfast chfast commented Jun 25, 2021

intx 0.6.0

Haswell 4.0 GHz, clang-12

Comparing o/main-master to o/main-intx06
Benchmark                                                                Time             CPU      Time Old      Time New       CPU Old       CPU New
-----------------------------------------------------------------------------------------------------------------------------------------------------
advanced/execute/main/blake2b_huff/empty_mean                         +0.0172         +0.0172            13            13            13            13
baseline/execute/main/blake2b_huff/empty_mean                         -0.0001         -0.0001            16            16            16            16
advanced/execute/main/blake2b_huff/2805nulls_mean                     +0.0181         +0.0180           275           280           275           280
baseline/execute/main/blake2b_huff/2805nulls_mean                     -0.0025         -0.0025           343           342           343           342
advanced/execute/main/blake2b_huff/5610nulls_mean                     +0.0197         +0.0197           536           547           536           547
baseline/execute/main/blake2b_huff/5610nulls_mean                     +0.0019         +0.0019           669           670           669           670
advanced/execute/main/blake2b_huff/8415nulls_mean                     +0.0189         +0.0189           785           800           785           800
baseline/execute/main/blake2b_huff/8415nulls_mean                     +0.0114         +0.0114           976           987           976           987
advanced/execute/main/blake2b_huff/65536nulls_mean                    +0.0152         +0.0152          6109          6202          6109          6202
baseline/execute/main/blake2b_huff/65536nulls_mean                    +0.0023         +0.0023          7603          7620          7603          7620
advanced/execute/main/blake2b_shifts/2805nulls_mean                   -0.0134         -0.0134          3798          3747          3798          3747
baseline/execute/main/blake2b_shifts/2805nulls_mean                   -0.0380         -0.0380          3382          3254          3382          3254
advanced/execute/main/blake2b_shifts/5610nulls_mean                   -0.0149         -0.0149          7586          7473          7586          7473
baseline/execute/main/blake2b_shifts/5610nulls_mean                   -0.0366         -0.0366          6750          6503          6750          6503
advanced/execute/main/blake2b_shifts/8415nulls_mean                   -0.0126         -0.0126         11353         11209         11353         11209
baseline/execute/main/blake2b_shifts/8415nulls_mean                   -0.0344         -0.0344         10122          9774         10123          9774
advanced/execute/main/blake2b_shifts/65536nulls_mean                  -0.0115         -0.0115         87868         86858         87868         86858
baseline/execute/main/blake2b_shifts/65536nulls_mean                  -0.0280         -0.0280         78062         75875         78062         75875
advanced/execute/main/sha1_divs/empty_mean                            -0.0079         -0.0079            56            56            56            56
baseline/execute/main/sha1_divs/empty_mean                            -0.0007         -0.0007            59            59            59            59
advanced/execute/main/sha1_divs/1351_mean                             -0.0014         -0.0014          1153          1152          1153          1152
baseline/execute/main/sha1_divs/1351_mean                             -0.0033         -0.0033          1230          1226          1230          1226
advanced/execute/main/sha1_divs/2737_mean                             -0.0002         -0.0002          2251          2250          2251          2250
baseline/execute/main/sha1_divs/2737_mean                             -0.0065         -0.0065          2407          2391          2407          2391
advanced/execute/main/sha1_divs/5311_mean                             +0.0015         +0.0015          4384          4391          4384          4391
baseline/execute/main/sha1_divs/5311_mean                             -0.0057         -0.0056          4694          4667          4694          4667
advanced/execute/main/sha1_divs/65536_mean                            +0.0008         +0.0008         53528         53572         53528         53572
baseline/execute/main/sha1_divs/65536_mean                            -0.0021         -0.0021         57029         56909         57029         56910
advanced/execute/main/sha1_shifts/empty_mean                          -0.0016         -0.0016            32            32            32            32
baseline/execute/main/sha1_shifts/empty_mean                          -0.0072         -0.0072            35            35            35            35
advanced/execute/main/sha1_shifts/1351_mean                           -0.0041         -0.0041           673           670           673           670
baseline/execute/main/sha1_shifts/1351_mean                           -0.0049         -0.0049           744           740           744           740
advanced/execute/main/sha1_shifts/2737_mean                           -0.0059         -0.0059          1315          1307          1315          1307
baseline/execute/main/sha1_shifts/2737_mean                           -0.0077         -0.0077          1460          1449          1460          1449
advanced/execute/main/sha1_shifts/5311_mean                           -0.0007         -0.0007          2558          2556          2558          2556
baseline/execute/main/sha1_shifts/5311_mean                           -0.0092         -0.0092          2844          2818          2845          2818
advanced/execute/main/sha1_shifts/65536_mean                          -0.0004         -0.0004         31126         31112         31126         31112
baseline/execute/main/sha1_shifts/65536_mean                          -0.0086         -0.0086         34792         34494         34792         34494
advanced/execute/main/weierstrudel/0_mean                             -0.0764         -0.0764           183           169           183           169
baseline/execute/main/weierstrudel/0_mean                             -0.0932         -0.0932           188           170           188           170
advanced/execute/main/weierstrudel/1_mean                             -0.1011         -0.1011           416           374           416           374
baseline/execute/main/weierstrudel/1_mean                             -0.0958         -0.0958           421           381           421           381
advanced/execute/main/weierstrudel/3_mean                             -0.1032         -0.1032           651           584           651           584
baseline/execute/main/weierstrudel/3_mean                             -0.0984         -0.0984           659           594           659           594
advanced/execute/main/weierstrudel/9_mean                             -0.1045         -0.1045          1351          1210          1351          1210
baseline/execute/main/weierstrudel/9_mean                             -0.1015         -0.1015          1372          1232          1372          1232
advanced/execute/main/weierstrudel/14_mean                            -0.1035         -0.1035          1934          1734          1934          1734

@chfast chfast requested review from axic and gumb0 June 25, 2021 12:30
@codecov
Copy link

codecov bot commented Jun 25, 2021

Codecov Report

Merging #345 (e86db4b) into master (742b817) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #345   +/-   ##
=======================================
  Coverage   99.78%   99.78%           
=======================================
  Files          30       30           
  Lines        4135     4139    +4     
=======================================
+ Hits         4126     4130    +4     
  Misses          9        9           
Flag Coverage Δ
consensus 91.07% <100.00%> (-0.04%) ⬇️
unittests 99.78% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
lib/evmone/instructions.hpp 100.00% <100.00%> (ø)
test/unittests/evm_test.cpp 99.70% <100.00%> (+<0.01%) ⬆️

const auto x_neg = x.hi.hi >> 63;
const auto y_neg = y.hi.hi >> 63;
y = ((x_neg ^ y_neg) != 0) ? y_neg : y < x;
stack[0] = slt(stack[0], x);
Copy link
Member

@axic axic Jun 25, 2021

Choose a reason for hiding this comment

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

Suggested change
stack[0] = slt(stack[0], x);
stack[0] = sgt(stack[0], x);

Where are your unit tests? 🙈

Edit: Did not notice the swapped operand order. Any reason not going for sgt instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

it was done to limit EVM-origin additions to intx. That would be different if intx had signed integers implementation.
Moreover, from the evmone PoW, it is better to use less functions - this is at least virtually less code. The LT/GT are implemented using the same pattern. Also because we know that operator> is implemented in terms of operator< - so we are avoiding some additional indirection.

The proposed change should work performance-wise. The issue is some kind of readability-performance tradeoff.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe just leave a comment above "Notice the swapped operands".

Copy link
Member Author

Choose a reason for hiding this comment

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

@chfast chfast merged commit e0a56ea into master Jun 28, 2021
@chfast chfast deleted the upgrade_intx branch June 28, 2021 07:22
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.

2 participants