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

Baseline threaded code (computed goto) #495

Merged
merged 4 commits into from
Aug 24, 2022
Merged

Baseline threaded code (computed goto) #495

merged 4 commits into from
Aug 24, 2022

Conversation

chfast
Copy link
Member

@chfast chfast commented Aug 20, 2022

This finally adds "computed goto" dispatch loop implementation. This is enabled by default for Baseline if a compiler supports the Labels as Values extension.

This was referenced Aug 20, 2022
@gcolvin
Copy link

gcolvin commented Aug 21, 2022

Sweet!

Am I reading this correctly? From the first two columns it looks like nothing got worse, and some got as much as 40% or more faster. But I don't really know what any of the columns mean.

@chfast
Copy link
Member Author

chfast commented Aug 21, 2022

Sweet!

Am I reading this correctly? From the first two columns it looks like nothing got worse, and some got as much as 40% or more faster. But I don't really know what any of the columns mean.

This is output from google/benchmark compare.py script.

Benchmark                                                                                     Time             CPU      Time Old      Time New       CPU Old       CPU New
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Only the first number matters which is the relative time change. (Negative values means the performance has increased). The wallclock and CPU times are almost the same. The other columns are the absolute timings, but are rather meaningless because the script rounds them and skips the units.

The numbers for GCC are not so great so I'm trying to figure out why. Maybe I will use static table of label addresses for start. When using dynamic table (selected by EVM revision) this occupies one register in the function.

@codecov
Copy link

codecov bot commented Aug 22, 2022

Codecov Report

Merging #495 (7d8c558) into master (b6080f1) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #495   +/-   ##
=======================================
  Coverage   99.40%   99.41%           
=======================================
  Files          53       53           
  Lines        5249     5272   +23     
=======================================
+ Hits         5218     5241   +23     
  Misses         31       31           
Flag Coverage Δ
consensus 77.95% <60.00%> (-1.11%) ⬇️
statetests 7.67% <29.16%> (+0.07%) ⬆️
unittests 99.55% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
lib/evmone/advanced_instructions.cpp 100.00% <ø> (ø)
lib/evmone/vm.hpp 100.00% <ø> (ø)
lib/evmone/baseline.cpp 100.00% <100.00%> (ø)
lib/evmone/instructions.hpp 100.00% <100.00%> (ø)
lib/evmone/vm.cpp 100.00% <100.00%> (ø)
test/unittests/evm_fixture.cpp 88.88% <100.00%> (+3.17%) ⬆️
test/unittests/evmone_test.cpp 100.00% <100.00%> (ø)

@chfast chfast force-pushed the baseline_cgoto branch 2 times, most recently from b55187a to 0f01455 Compare August 23, 2022 12:15
@chfast chfast marked this pull request as ready for review August 23, 2022 12:17
@yperbasis
Copy link
Member

What are the benchmark results?

@chfast
Copy link
Member Author

chfast commented Aug 23, 2022

Benchmark results

Clang 15, Haswell: 7%
[bnocgoto vs. baseline]/execute/main/blake2b_huff/empty_mean                               -0.1422         -0.1422            13            11            13            11
[bnocgoto vs. baseline]/execute/main/blake2b_huff/2805nulls_mean                           -0.1425         -0.1425           289           247           289           247
[bnocgoto vs. baseline]/execute/main/blake2b_huff/5610nulls_mean                           -0.1489         -0.1489           567           482           567           482
[bnocgoto vs. baseline]/execute/main/blake2b_huff/8415nulls_mean                           -0.1413         -0.1413           824           707           824           707
[bnocgoto vs. baseline]/execute/main/blake2b_huff/65536nulls_mean                          -0.1409         -0.1409          6383          5484          6383          5484
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/2805nulls_mean                         -0.1608         -0.1608          2814          2362          2814          2362
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/5610nulls_mean                         -0.1706         -0.1706          5709          4735          5709          4735
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/8415nulls_mean                         -0.1525         -0.1525          8381          7103          8381          7103
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/65536nulls_mean                        -0.1520         -0.1520         64886         55024         64887         55025
[bnocgoto vs. baseline]/execute/main/sha1_divs/empty_mean                                  -0.0491         -0.0491            53            50            53            50
[bnocgoto vs. baseline]/execute/main/sha1_divs/1351_mean                                   -0.0454         -0.0454          1103          1053          1103          1053
[bnocgoto vs. baseline]/execute/main/sha1_divs/2737_mean                                   -0.0447         -0.0447          2150          2054          2150          2054
[bnocgoto vs. baseline]/execute/main/sha1_divs/5311_mean                                   -0.0468         -0.0468          4202          4006          4202          4006
[bnocgoto vs. baseline]/execute/main/sha1_divs/65536_mean                                  -0.0463         -0.0463         51231         48858         51231         48859
[bnocgoto vs. baseline]/execute/main/sha1_shifts/empty_mean                                -0.0758         -0.0758            30            27            30            27
[bnocgoto vs. baseline]/execute/main/sha1_shifts/1351_mean                                 -0.0666         -0.0666           631           589           631           589
[bnocgoto vs. baseline]/execute/main/sha1_shifts/2737_mean                                 -0.0680         -0.0680          1233          1149          1233          1149
[bnocgoto vs. baseline]/execute/main/sha1_shifts/5311_mean                                 -0.0694         -0.0694          2410          2243          2410          2243
[bnocgoto vs. baseline]/execute/main/sha1_shifts/65536_mean                                -0.0807         -0.0807         29799         27393         29799         27393
[bnocgoto vs. baseline]/execute/main/weierstrudel/0_mean                                   -0.0212         -0.0212           164           160           164           160
[bnocgoto vs. baseline]/execute/main/weierstrudel/1_mean                                   -0.0345         -0.0345           361           349           361           349
[bnocgoto vs. baseline]/execute/main/weierstrudel/3_mean                                   -0.0324         -0.0324           562           543           562           543
[bnocgoto vs. baseline]/execute/main/weierstrudel/9_mean                                   -0.0357         -0.0357          1164          1123          1164          1123
[bnocgoto vs. baseline]/execute/main/weierstrudel/14_mean                                  -0.0361         -0.0361          1666          1606          1666          1606
[bnocgoto vs. baseline]/execute/micro/jump_around/empty_mean                               -0.1220         -0.1220            26            23            26            23
[bnocgoto vs. baseline]/execute/micro/jumpdests_0xffff/empty_mean                          +0.0109         +0.0109           111           112           111           112
[bnocgoto vs. baseline]/execute/micro/loop_with_many_jumpdests/empty_mean                  -0.0271         -0.0271         14759         14360         14759         14360
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/nogrow_mean                        -0.0575         -0.0575            49            46            49            46
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by1_mean                           -0.0596         -0.0596            52            49            52            49
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by16_mean                          -0.0681         -0.0681            58            54            58            54
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by32_mean                          -0.0675         -0.0675            66            62            66            62
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/nogrow_mean                       -0.0253         -0.0253            51            49            51            49
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by1_mean                          -0.0287         -0.0287            55            53            55            53
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by16_mean                         -0.0032         -0.0032            61            61            61            61
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by32_mean                         -0.0130         -0.0130            73            72            73            72
[bnocgoto vs. baseline]/execute/micro/signextend/zero_mean                                 -0.1160         -0.1160            66            59            66            59
[bnocgoto vs. baseline]/execute/micro/signextend/one_mean                                  -0.1150         -0.1150            66            59            66            59
OVERALL_GEOMEAN                                                                            -0.0769         -0.0769             0             0             0             0
GCC 12, Haswell: 1%
[bnocgoto vs. baseline]/execute/main/blake2b_huff/empty_mean                               -0.0069         -0.0069            14            14            14            14
[bnocgoto vs. baseline]/execute/main/blake2b_huff/2805nulls_mean                           -0.0044         -0.0044           317           315           317           315
[bnocgoto vs. baseline]/execute/main/blake2b_huff/5610nulls_mean                           -0.0046         -0.0046           619           616           619           616
[bnocgoto vs. baseline]/execute/main/blake2b_huff/8415nulls_mean                           -0.0043         -0.0043           907           903           907           903
[bnocgoto vs. baseline]/execute/main/blake2b_huff/65536nulls_mean                          -0.0049         -0.0049          7049          7015          7049          7015
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/2805nulls_mean                         +0.0037         +0.0037          2744          2754          2744          2754
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/5610nulls_mean                         +0.0053         +0.0053          5465          5494          5465          5494
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/8415nulls_mean                         +0.0069         +0.0069          8190          8246          8190          8246
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/65536nulls_mean                        +0.0055         +0.0055         63504         63851         63504         63852
[bnocgoto vs. baseline]/execute/main/sha1_divs/empty_mean                                  -0.0159         -0.0159            51            50            51            50
[bnocgoto vs. baseline]/execute/main/sha1_divs/1351_mean                                   +0.0048         +0.0048          1066          1071          1066          1071
[bnocgoto vs. baseline]/execute/main/sha1_divs/2737_mean                                   +0.0025         +0.0025          2083          2088          2083          2088
[bnocgoto vs. baseline]/execute/main/sha1_divs/5311_mean                                   +0.0038         +0.0038          4063          4078          4063          4078
[bnocgoto vs. baseline]/execute/main/sha1_divs/65536_mean                                  +0.0038         +0.0038         49465         49651         49465         49651
[bnocgoto vs. baseline]/execute/main/sha1_shifts/empty_mean                                -0.0257         -0.0258            25            24            25            24
[bnocgoto vs. baseline]/execute/main/sha1_shifts/1351_mean                                 -0.0245         -0.0245           533           520           533           520
[bnocgoto vs. baseline]/execute/main/sha1_shifts/2737_mean                                 -0.0243         -0.0243          1042          1016          1042          1016
[bnocgoto vs. baseline]/execute/main/sha1_shifts/5311_mean                                 -0.0239         -0.0239          2032          1984          2032          1984
[bnocgoto vs. baseline]/execute/main/sha1_shifts/65536_mean                                -0.0248         -0.0248         24788         24173         24789         24173
[bnocgoto vs. baseline]/execute/main/weierstrudel/0_mean                                   -0.0113         -0.0113           244           242           244           242
[bnocgoto vs. baseline]/execute/main/weierstrudel/1_mean                                   -0.0174         -0.0174           535           525           535           525
[bnocgoto vs. baseline]/execute/main/weierstrudel/3_mean                                   -0.0150         -0.0150           839           826           839           826
[bnocgoto vs. baseline]/execute/main/weierstrudel/9_mean                                   -0.0140         -0.0140          1740          1716          1740          1716
[bnocgoto vs. baseline]/execute/main/weierstrudel/14_mean                                  -0.0124         -0.0124          2493          2462          2493          2462
[bnocgoto vs. baseline]/execute/micro/jump_around/empty_mean                               -0.0112         -0.0112            23            23            23            23
[bnocgoto vs. baseline]/execute/micro/jumpdests_0xffff/empty_mean                          -0.0218         -0.0218           108           105           108           105
[bnocgoto vs. baseline]/execute/micro/loop_with_many_jumpdests/empty_mean                  -0.0182         -0.0182         14031         13776         14031         13776
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/nogrow_mean                        -0.0000         -0.0000            63            63            63            63
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by1_mean                           -0.0008         -0.0008            64            64            64            64
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by16_mean                          -0.0081         -0.0081            72            71            72            71
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by32_mean                          -0.0111         -0.0111            81            80            81            80
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/nogrow_mean                       -0.0591         -0.0591            51            48            51            48
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by1_mean                          -0.0302         -0.0302            52            50            52            50
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by16_mean                         -0.0347         -0.0347            62            60            62            60
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by32_mean                         -0.0197         -0.0197            73            71            73            71
[bnocgoto vs. baseline]/execute/micro/signextend/zero_mean                                 -0.0441         -0.0441            55            52            55            52
[bnocgoto vs. baseline]/execute/micro/signextend/one_mean                                  -0.0433         -0.0433            55            52            55            52
OVERALL_GEOMEAN                                                                            -0.0137         -0.0137             0             0             0             0
Clang 13, Skylake: 10%
[bnocgoto vs. baseline]/execute/main/blake2b_huff/empty_mean                               -0.1647         -0.1647            13            11            13            11
[bnocgoto vs. baseline]/execute/main/blake2b_huff/2805nulls_mean                           -0.1671         -0.1671           292           243           292           243
[bnocgoto vs. baseline]/execute/main/blake2b_huff/5610nulls_mean                           -0.1681         -0.1681           567           472           567           472
[bnocgoto vs. baseline]/execute/main/blake2b_huff/8415nulls_mean                           -0.1650         -0.1650           834           696           834           696
[bnocgoto vs. baseline]/execute/main/blake2b_huff/65536nulls_mean                          -0.1686         -0.1687          6463          5373          6463          5373
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/2805nulls_mean                         -0.1755         -0.1755          2692          2220          2692          2219
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/5610nulls_mean                         -0.1730         -0.1730          5362          4434          5362          4434
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/8415nulls_mean                         -0.1703         -0.1703          8005          6642          8005          6642
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/65536nulls_mean                        -0.1721         -0.1721         62371         51637         62369         51635
[bnocgoto vs. baseline]/execute/main/sha1_divs/empty_mean                                  -0.0567         -0.0567            48            45            48            45
[bnocgoto vs. baseline]/execute/main/sha1_divs/1351_mean                                   -0.0589         -0.0589           998           939           998           939
[bnocgoto vs. baseline]/execute/main/sha1_divs/2737_mean                                   -0.0588         -0.0588          1931          1817          1931          1817
[bnocgoto vs. baseline]/execute/main/sha1_divs/5311_mean                                   -0.0502         -0.0502          3755          3567          3755          3567
[bnocgoto vs. baseline]/execute/main/sha1_divs/65536_mean                                  -0.0505         -0.0505         45650         43344         45649         43342
[bnocgoto vs. baseline]/execute/main/sha1_shifts/empty_mean                                -0.1035         -0.1035            29            26            29            26
[bnocgoto vs. baseline]/execute/main/sha1_shifts/1351_mean                                 -0.1004         -0.1004           610           548           610           548
[bnocgoto vs. baseline]/execute/main/sha1_shifts/2737_mean                                 -0.0966         -0.0966          1185          1070          1185          1070
[bnocgoto vs. baseline]/execute/main/sha1_shifts/5311_mean                                 -0.1038         -0.1037          2308          2068          2308          2068
[bnocgoto vs. baseline]/execute/main/sha1_shifts/65536_mean                                -0.1067         -0.1067         28173         25167         28172         25166
[bnocgoto vs. baseline]/execute/main/weierstrudel/0_mean                                   -0.0091         -0.0091           148           147           148           147
[bnocgoto vs. baseline]/execute/main/weierstrudel/1_mean                                   -0.0223         -0.0222           326           318           326           318
[bnocgoto vs. baseline]/execute/main/weierstrudel/3_mean                                   -0.0209         -0.0209           509           498           509           498
[bnocgoto vs. baseline]/execute/main/weierstrudel/9_mean                                   -0.0186         -0.0186          1048          1029          1048          1029
[bnocgoto vs. baseline]/execute/main/weierstrudel/14_mean                                  -0.0220         -0.0220          1505          1472          1505          1472
[bnocgoto vs. baseline]/execute/micro/jump_around/empty_mean                               -0.0982         -0.0982            28            25            28            25
[bnocgoto vs. baseline]/execute/micro/jumpdests_0xffff/empty_mean                          -0.0811         -0.0811            80            73            80            73
[bnocgoto vs. baseline]/execute/micro/loop_with_many_jumpdests/empty_mean                  -0.1082         -0.1081          9649          8606          9649          8605
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/nogrow_mean                        -0.0978         -0.0978            48            43            48            43
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by1_mean                           -0.0870         -0.0870            51            47            51            47
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by16_mean                          -0.0596         -0.0596            56            53            56            53
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by32_mean                          -0.0551         -0.0551            63            60            63            60
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/nogrow_mean                       -0.0795         -0.0795            48            44            48            44
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by1_mean                          -0.0729         -0.0729            51            47            51            47
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by16_mean                         -0.0577         -0.0577            57            54            57            54
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by32_mean                         -0.0538         -0.0538            67            63            67            63
[bnocgoto vs. baseline]/execute/micro/signextend/zero_mean                                 -0.2587         -0.2587            74            55            74            55
[bnocgoto vs. baseline]/execute/micro/signextend/one_mean                                  -0.2549         -0.2549            74            55            74            55
OVERALL_GEOMEAN                                                                            -0.1041         -0.1041             0             0             0             0
Clang 15, Skylake 11%
[bnocgoto vs. baseline]/execute/main/blake2b_huff/empty_mean                               -0.1757         -0.1757            16            13            16            13
[bnocgoto vs. baseline]/execute/main/blake2b_huff/2805nulls_mean                           -0.1703         -0.1703           340           282           340           282
[bnocgoto vs. baseline]/execute/main/blake2b_huff/5610nulls_mean                           -0.1767         -0.1767           665           548           665           548
[bnocgoto vs. baseline]/execute/main/blake2b_huff/8415nulls_mean                           -0.1723         -0.1723           974           806           974           806
[bnocgoto vs. baseline]/execute/main/blake2b_huff/65536nulls_mean                          -0.1826         -0.1826          7615          6225          7615          6225
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/2805nulls_mean                         -0.2145         -0.2145          3174          2493          3174          2493
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/5610nulls_mean                         -0.2057         -0.2057          6322          5021          6322          5021
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/8415nulls_mean                         -0.2004         -0.2004          9365          7488          9365          7488
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/65536nulls_mean                        -0.2130         -0.2130         73398         57763         73394         57760
[bnocgoto vs. baseline]/execute/main/sha1_divs/empty_mean                                  -0.0626         -0.0626            53            50            53            50
[bnocgoto vs. baseline]/execute/main/sha1_divs/1351_mean                                   -0.0716         -0.0716          1119          1039          1119          1039
[bnocgoto vs. baseline]/execute/main/sha1_divs/2737_mean                                   -0.0809         -0.0809          2174          1998          2173          1998
[bnocgoto vs. baseline]/execute/main/sha1_divs/5311_mean                                   -0.0698         -0.0698          4205          3911          4204          3911
[bnocgoto vs. baseline]/execute/main/sha1_divs/65536_mean                                  -0.0846         -0.0846         51568         47204         51567         47202
[bnocgoto vs. baseline]/execute/main/sha1_shifts/empty_mean                                -0.0927         -0.0927            32            29            32            29
[bnocgoto vs. baseline]/execute/main/sha1_shifts/1351_mean                                 -0.0851         -0.0851           684           625           684           625
[bnocgoto vs. baseline]/execute/main/sha1_shifts/2737_mean                                 -0.0847         -0.0847          1317          1205          1317          1205
[bnocgoto vs. baseline]/execute/main/sha1_shifts/5311_mean                                 -0.0806         -0.0806          2561          2354          2561          2354
[bnocgoto vs. baseline]/execute/main/sha1_shifts/65536_mean                                -0.0793         -0.0793         31022         28563         31021         28562
[bnocgoto vs. baseline]/execute/main/weierstrudel/0_mean                                   -0.0173         -0.0173           165           162           165           162
[bnocgoto vs. baseline]/execute/main/weierstrudel/1_mean                                   -0.0277         -0.0277           363           353           363           353
[bnocgoto vs. baseline]/execute/main/weierstrudel/3_mean                                   -0.0322         -0.0322           569           551           569           551
[bnocgoto vs. baseline]/execute/main/weierstrudel/9_mean                                   -0.0389         -0.0389          1171          1126          1171          1125
[bnocgoto vs. baseline]/execute/main/weierstrudel/14_mean                                  -0.0316         -0.0316          1660          1607          1660          1607
[bnocgoto vs. baseline]/execute/micro/jump_around/empty_mean                               -0.0109         -0.0109            27            27            27            27
[bnocgoto vs. baseline]/execute/micro/jumpdests_0xffff/empty_mean                          -0.0139         -0.0139            78            77            78            77
[bnocgoto vs. baseline]/execute/micro/loop_with_many_jumpdests/empty_mean                  -0.0005         -0.0005          9400          9395          9399          9394
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/nogrow_mean                        -0.1116         -0.1116            54            48            54            48
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by1_mean                           -0.1117         -0.1117            59            53            59            52
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by16_mean                          -0.4076         -0.4076           100            59           100            59
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by32_mean                          -0.1171         -0.1171            76            67            76            67
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/nogrow_mean                       -0.1462         -0.1462            59            51            59            51
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by1_mean                          -0.1332         -0.1332            62            54            62            54
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by16_mean                         -0.1517         -0.1517            72            61            72            61
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by32_mean                         -0.1351         -0.1351            82            71            82            71
[bnocgoto vs. baseline]/execute/micro/signextend/zero_mean                                 +0.0159         +0.0160            70            71            70            71
[bnocgoto vs. baseline]/execute/micro/signextend/one_mean                                  +0.0190         +0.0189            70            71            70            71
OVERALL_GEOMEAN                                                                            -0.1112         -0.1112             0             0             0             0
GCC 12, Skylake: 2%
[bnocgoto vs. baseline]/execute/main/blake2b_huff/empty_mean                               -0.0199         -0.0200            14            14            14            14
[bnocgoto vs. baseline]/execute/main/blake2b_huff/2805nulls_mean                           -0.0085         -0.0085           310           308           310           308
[bnocgoto vs. baseline]/execute/main/blake2b_huff/5610nulls_mean                           -0.0111         -0.0111           608           601           608           601
[bnocgoto vs. baseline]/execute/main/blake2b_huff/8415nulls_mean                           -0.0084         -0.0084           887           880           887           880
[bnocgoto vs. baseline]/execute/main/blake2b_huff/65536nulls_mean                          -0.0091         -0.0091          6919          6856          6919          6856
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/2805nulls_mean                         -0.0327         -0.0327          2695          2607          2695          2607
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/5610nulls_mean                         -0.0312         -0.0312          5380          5212          5380          5212
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/8415nulls_mean                         -0.0275         -0.0275          8047          7826          8047          7825
[bnocgoto vs. baseline]/execute/main/blake2b_shifts/65536nulls_mean                        -0.0276         -0.0276         62323         60603         62320         60600
[bnocgoto vs. baseline]/execute/main/sha1_divs/empty_mean                                  -0.0368         -0.0368            49            47            49            47
[bnocgoto vs. baseline]/execute/main/sha1_divs/1351_mean                                   -0.0175         -0.0175          1028          1010          1028          1010
[bnocgoto vs. baseline]/execute/main/sha1_divs/2737_mean                                   -0.0242         -0.0242          1996          1948          1996          1948
[bnocgoto vs. baseline]/execute/main/sha1_divs/5311_mean                                   -0.0187         -0.0187          3870          3797          3870          3797
[bnocgoto vs. baseline]/execute/main/sha1_divs/65536_mean                                  -0.0186         -0.0186         46916         46043         46914         46042
[bnocgoto vs. baseline]/execute/main/sha1_shifts/empty_mean                                -0.0332         -0.0332            25            24            25            24
[bnocgoto vs. baseline]/execute/main/sha1_shifts/1351_mean                                 -0.0288         -0.0288           530           515           530           515
[bnocgoto vs. baseline]/execute/main/sha1_shifts/2737_mean                                 -0.0303         -0.0303          1031           999          1031           999
[bnocgoto vs. baseline]/execute/main/sha1_shifts/5311_mean                                 -0.0373         -0.0373          2002          1927          2002          1927
[bnocgoto vs. baseline]/execute/main/sha1_shifts/65536_mean                                -0.0349         -0.0349         24114         23273         24113         23272
[bnocgoto vs. baseline]/execute/main/weierstrudel/0_mean                                   -0.0021         -0.0021           212           211           212           211
[bnocgoto vs. baseline]/execute/main/weierstrudel/1_mean                                   -0.0109         -0.0109           465           460           465           460
[bnocgoto vs. baseline]/execute/main/weierstrudel/3_mean                                   -0.0097         -0.0097           724           717           724           717
[bnocgoto vs. baseline]/execute/main/weierstrudel/9_mean                                   -0.0024         -0.0024          1482          1479          1482          1479
[bnocgoto vs. baseline]/execute/main/weierstrudel/14_mean                                  +0.0015         +0.0015          2113          2116          2113          2116
[bnocgoto vs. baseline]/execute/micro/jump_around/empty_mean                               -0.0827         -0.0827            22            21            22            21
[bnocgoto vs. baseline]/execute/micro/jumpdests_0xffff/empty_mean                          +0.0261         +0.0261            72            74            72            74
[bnocgoto vs. baseline]/execute/micro/loop_with_many_jumpdests/empty_mean                  -0.0005         -0.0005          8690          8686          8690          8685
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/nogrow_mean                        -0.0033         -0.0033            59            59            59            59
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by1_mean                           -0.0052         -0.0052            60            60            60            60
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by16_mean                          -0.0129         -0.0129            70            69            70            69
[bnocgoto vs. baseline]/execute/micro/memory_grow_mload/by32_mean                          -0.0193         -0.0193            77            76            77            76
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/nogrow_mean                       -0.0302         -0.0302            48            47            48            47
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by1_mean                          -0.0244         -0.0244            49            48            49            48
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by16_mean                         -0.0211         -0.0212            58            56            58            56
[bnocgoto vs. baseline]/execute/micro/memory_grow_mstore/by32_mean                         -0.0184         -0.0184            67            66            67            66
[bnocgoto vs. baseline]/execute/micro/signextend/zero_mean                                 -0.1905         -0.1905            62            50            62            50
[bnocgoto vs. baseline]/execute/micro/signextend/one_mean                                  -0.1989         -0.1989            63            50            63            50
OVERALL_GEOMEAN                                                                            -0.0297         -0.0297             0             0             0             0

Summary

The improvements for GCC are minimal, but at least it is not a regression. Clang benefits more.

Run benchmarks

Run benchmarks yourself and attach the results.json file for further analysis.

bin/evmone-bench ../../test/benchmarks --benchmark_display_aggregates_only --benchmark_filter='/execute/' --benchmark_repetitions=23 --benchmark_min_time=0.1 --benchmark_out=results.json

lib/evmone/baseline.cpp Outdated Show resolved Hide resolved
dispatch<false>(cost_table, state);
{
#if EVMONE_CGOTO_SUPPORTED
if (vm.cgoto)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if making this else if (INTX_LIKELY(vm.cgoto)) can trigger any better layout? Since the default case is cgoto unless disabled.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't want to use likely/unlikely here, because there is a chance compiler will compile the unlikely branch for code size. I want them to have equal chances because they are competing against each other in benchmarks.

@@ -276,7 +323,14 @@ evmc_result execute(const VM& vm, ExecutionState& state, const CodeAnalysis& ana
if (INTX_UNLIKELY(tracer != nullptr))
dispatch<true>(cost_table, state, tracer);
else
dispatch<false>(cost_table, state);
{
#if EVMONE_CGOTO_SUPPORTED
Copy link
Member Author

Choose a reason for hiding this comment

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

We can eliminate the #if by providing a stub dispatch_cgoto() implementation for unsupported compilers and making sure vm.cgoto is always false. However, the last condition can only be checked at runtime. With the current version we will get compilation error if something is messed up.

lib/evmone/vm.cpp Show resolved Hide resolved
chfast and others added 4 commits August 24, 2022 18:19
Add option to handle undefined opcodes,
do not pass identifier by default.
Add EVMC option cgoto=no to disable the "computed goto" dispatch
in Baseline.
@chfast chfast merged commit 33eec57 into master Aug 24, 2022
@chfast chfast deleted the baseline_cgoto branch August 24, 2022 17:52
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.

4 participants