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

PoC: assume code ends with STOP #295

Closed
wants to merge 2 commits into from
Closed

PoC: assume code ends with STOP #295

wants to merge 2 commits into from

Conversation

chfast
Copy link
Member

@chfast chfast commented Mar 31, 2021

Assumption that code always ends with valid STOP instruction eliminates the "end-of-code" checks in the interpreter loop and in push data load. See individual commits for more information.

Benchmarks with evmone/Baseline interpreter build with Clang 11 on Haswell CPU 4.0 GHz, "main" benchmark set:

  • time reduced by -2% to -11%,
  • geometric mean: -7.2%.
Comparing o/baseline to o/valid_stop                                                                                                                                                                                              
Benchmark                                                                Time             CPU      Time Old      Time New       CPU Old       CPU New                                                                             
-----------------------------------------------------------------------------------------------------------------------------------------------------
baseline/execute/main/blake2b_huff/empty_mean                         -0.0617         -0.0618            25            23            25            23
baseline/execute/main/blake2b_huff/2805nulls_mean                     -0.1125         -0.1125           408           362           408           362
baseline/execute/main/blake2b_huff/5610nulls_mean                     -0.1004         -0.1004           783           704           783           704
baseline/execute/main/blake2b_huff/8415nulls_mean                     -0.1051         -0.1051          1148          1027          1148          1027
baseline/execute/main/blake2b_huff/65536nulls_mean                    -0.1039         -0.1039          8843          7924          8843          7924
baseline/execute/main/blake2b_shifts/2805nulls_mean                   -0.0740         -0.0740          3945          3653          3945          3653
baseline/execute/main/blake2b_shifts/5610nulls_mean                   -0.0810         -0.0810          8156          7495          8156          7495
baseline/execute/main/blake2b_shifts/8415nulls_mean                   -0.0814         -0.0814         12305         11303         12305         11303
baseline/execute/main/blake2b_shifts/65536nulls_mean                  -0.0897         -0.0897         89394         81377         89394         81378
baseline/execute/main/sha1_divs/empty_mean                            -0.0539         -0.0538            65            61            65            61
baseline/execute/main/sha1_divs/1351_mean                             -0.0570         -0.0570          1329          1254          1329          1254
baseline/execute/main/sha1_divs/2737_mean                             -0.0539         -0.0539          2593          2453          2593          2453
baseline/execute/main/sha1_divs/5311_mean                             -0.0573         -0.0573          5071          4780          5071          4780
baseline/execute/main/sha1_divs/65536_mean                            -0.0562         -0.0561         61711         58245         61711         58246
baseline/execute/main/sha1_shifts/empty_mean                          -0.0960         -0.0960            42            38            42            38
baseline/execute/main/sha1_shifts/1351_mean                           -0.1126         -0.1126           868           770           868           770
baseline/execute/main/sha1_shifts/2737_mean                           -0.1036         -0.1036          1677          1503          1677          1503
baseline/execute/main/sha1_shifts/5311_mean                           -0.1062         -0.1062          3287          2938          3287          2938
baseline/execute/main/sha1_shifts/65536_mean                          -0.0990         -0.0990         39656         35729         39656         35730
baseline/execute/main/weierstrudel/0_mean                             -0.0261         -0.0261           198           192           198           192
baseline/execute/main/weierstrudel/1_mean                             -0.0250         -0.0250           434           423           434           423
baseline/execute/main/weierstrudel/3_mean                             -0.0259         -0.0259           675           658           675           658
baseline/execute/main/weierstrudel/9_mean                             -0.0201         -0.0201          1393          1365          1393          1365
baseline/execute/main/weierstrudel/14_mean                            -0.0196         -0.0196          1992          1953          1992          1953

chfast added 2 commits March 31, 2021 22:06
Guaranteed to terminate because code must end with STOP.
This cannot overflow code buffer because code ends with valid STOP
instruction.
@chfast
Copy link
Member Author

chfast commented Jun 1, 2021

This optimization is enabled in #315 by copying and padding the original code.

@chfast chfast closed this Jun 1, 2021
@chfast chfast deleted the valid_stop branch June 1, 2021 08:54
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.

1 participant