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 WABT to 1.0.19 #443

Merged
merged 2 commits into from
Sep 28, 2020
Merged

Upgrade WABT to 1.0.19 #443

merged 2 commits into from
Sep 28, 2020

Conversation

chfast
Copy link
Collaborator

@chfast chfast commented Jul 29, 2020

For reference, here's PR intoducing new API: WebAssembly/wabt#1330

@codecov
Copy link

codecov bot commented Jul 29, 2020

Codecov Report

Merging #443 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #443      +/-   ##
==========================================
+ Coverage   98.61%   98.64%   +0.02%     
==========================================
  Files          59       59              
  Lines        8912     8932      +20     
==========================================
+ Hits         8789     8811      +22     
+ Misses        123      121       -2     


// Run start function (this will return ok if no start function is present)
const wabt::interp::ExecResult r = m_executor.RunStartFunction(m_module);
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 now executed properly by instantiate?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, looks like so, our unit test for this passes.

test/utils/wabt_engine.cpp Outdated Show resolved Hide resolved
}

WasmEngine::Result WabtEngine::execute(
WasmEngine::FuncRef func_ref, const std::vector<uint64_t>& args)
{
const auto* e = reinterpret_cast<const wabt::interp::Export*>(func_ref);
assert(m_instance);
Copy link
Member

Choose a reason for hiding this comment

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

Why assert here and not in init_memory/get_memory? I think we have the "rules" described in wasm_engine.h, I can't remember myself.

Copy link
Collaborator

Choose a reason for hiding this comment

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

wasm_engine.hpp says for all threeRequires instantiate()., though it seems ambiguous whether it means "assumes instantiate was called" or "fails when instantiate was not called".

But I see that here it's inconsitent now, I guess I'll change it to asserts in all three, fizzy_engine also assumes m_instance is non-null there.

@gumb0 gumb0 force-pushed the upgrade_wabt branch 2 times, most recently from feb9550 to e7e2b09 Compare September 15, 2020 14:57
@gumb0 gumb0 force-pushed the upgrade_wabt branch 3 times, most recently from a03c67b to 7ce690a Compare September 15, 2020 16:08
test/utils/wabt_engine.cpp Outdated Show resolved Hide resolved
@axic
Copy link
Member

axic commented Sep 16, 2020

Can you also squash the commits? I think this is ready now, isn't it?

@gumb0 gumb0 marked this pull request as ready for review September 16, 2020 13:14
Copy link
Member

@axic axic left a comment

Choose a reason for hiding this comment

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

Looks good to me, we should have a benchmarking comparing this to 1.0.12 though.

@axic
Copy link
Member

axic commented Sep 16, 2020

@chfast waiting for your review

@chfast
Copy link
Collaborator Author

chfast commented Sep 16, 2020

Comparing wabt-1.0.12 to wabt-1.0.19                                                                                                                                    
Benchmark                                                            Time             CPU      Time Old      Time New       CPU Old       CPU New                       
-------------------------------------------------------------------------------------------------------------------------------------------------
 wabt/parse/blake2b_mean                                          -0.0325         -0.0325            72            70            72            70                       
 wabt/instantiate/blake2b_mean                                    +0.0876         +0.0876            78            85            78            85                       
 wabt/execute/blake2b/512_bytes_rounds_1_mean                     +2.0244         +2.0244           154           466           154           466                       
 wabt/execute/blake2b/512_bytes_rounds_16_mean                    +2.0314         +2.0314          2356          7141          2356          7141                       
 wabt/parse/ecpairing_mean                                        +0.0098         +0.0098          4115          4156          4115          4156                       
 wabt/instantiate/ecpairing_mean                                  +0.0455         +0.0455          4148          4336          4147          4336                       
 wabt/execute/ecpairing/onepoint_mean                             +2.0233         +2.0233        720502       2178284        720507       2178307                       
 wabt/parse/keccak256_mean                                        -0.0074         -0.0074           120           119           120           119                       
 wabt/instantiate/keccak256_mean                                  +0.1054         +0.1054           123           136           123           136                       
 wabt/execute/keccak256/512_bytes_rounds_1_mean                   +1.5514         +1.5514           173           441           173           441                       
 wabt/execute/keccak256/512_bytes_rounds_16_mean                  +1.5498         +1.5498          2543          6485          2543          6485                       
 wabt/parse/memset_mean                                           -0.1456         -0.1455            19            16            19            16                       
 wabt/instantiate/memset_mean                                     +0.1560         +0.1560            23            27            23            27
 wabt/execute/memset/256_bytes_mean                               +2.2922         +2.2921            11            38            11            38
 wabt/execute/memset/60000_bytes_mean                             +2.2041         +2.2041          2521          8077          2521          8077
 wabt/parse/mul256_opt0_mean                                      -0.1522         -0.1522            24            20            24            20
 wabt/instantiate/mul256_opt0_mean                                +0.1650         +0.1650            27            32            27            32
 wabt/execute/mul256_opt0/input0_mean                             +2.5594         +2.5594            44           158            44           158
 wabt/execute/mul256_opt0/input1_mean                             +2.5540         +2.5540            45           158            45           158
 wabt/parse/ramanujan_pi_mean                                     -0.0393         -0.0393            65            62            65            62
 wabt/instantiate/ramanujan_pi_mean                               +0.1558         +0.1558            68            78            68            78
 wabt/execute/ramanujan_pi/33_runs_mean                           +1.8711         +1.8711           237           679           237           679
 wabt/parse/sha1_mean                                             -0.0246         -0.0246           113           110           113           110
 wabt/instantiate/sha1_mean                                       +0.0554         +0.0554           116           123           116           123
 wabt/execute/sha1/512_bytes_rounds_1_mean                        +2.2715         +2.2715           174           568           174           568
 wabt/execute/sha1/512_bytes_rounds_16_mean                       +2.2881         +2.2881          2415          7940          2415          7940
 wabt/parse/sha256_mean                                           -0.0246         -0.0246           198           193           198           193
 wabt/instantiate/sha256_mean                                     +0.0445         +0.0445           202           211           202           211
 wabt/execute/sha256/512_bytes_rounds_1_mean                      +1.9267         +1.9267           188           551           188           551
 wabt/execute/sha256/512_bytes_rounds_16_mean                     +1.9418         +1.9418          2599          7647          2599          7647
 wabt/parse/taylor_pi_mean                                        -0.3610         -0.3610             9             6             9             6
 wabt/instantiate/taylor_pi_mean                                  +0.2191         +0.2191            14            17            14            17
 wabt/execute/taylor_pi/pi_1000000_runs_mean                      +1.7793         +1.7793         70885        197008         70885        197010
 wabt/parse/micro/eli_interpreter_mean                            -0.2105         -0.2105            12             9            12             9
 wabt/instantiate/micro/eli_interpreter_mean                      +0.1291         +0.1291            16            19            16            19
 wabt/execute/micro/eli_interpreter/halt_mean                    +19.4798        +19.4796             0             3             0             3
 wabt/execute/micro/eli_interpreter/exec105_mean                +152.1850       +152.1849             0            19             0            19
 wabt/parse/micro/factorial_mean                                  -0.0874         -0.0874             2             2             2             2
 wabt/instantiate/micro/factorial_mean                            +0.5015         +0.5015             2             3             2             3
 wabt/execute/micro/factorial/10_mean                             +8.1540         +8.1538             0             3             0             3
 wabt/execute/micro/factorial/20_mean                             +5.6214         +5.6213             1             4             1             4
 wabt/parse/micro/fibonacci_mean                                  -0.0653         -0.0653             3             3             3             3
 wabt/instantiate/micro/fibonacci_mean                            +0.3994         +0.3994             3             4             3             4
 wabt/execute/micro/fibonacci/24_mean                             +2.1884         +2.1884          5812         18529          5812         18529
 wabt/parse/micro/host_adler32_mean                               -0.3049         -0.3049             5             3             5             3
 wabt/instantiate/micro/host_adler32_mean                         +0.1657         +0.1657             7             8             7             8
 wabt/execute/micro/host_adler32/1_mean                           +0.1405         +0.1405             2             3             2             3
 wabt/execute/micro/host_adler32/100_mean                         -0.9252         -0.9252           219            16           219            16
 wabt/execute/micro/host_adler32/1000_mean                        -0.9273         -0.9273          2184           159          2184           159
 wabt/parse/micro/spinner_mean                                    -0.1156         -0.1156             2             2             2             2
 wabt/instantiate/micro/spinner_mean                              +0.5635         +0.5635             2             3             2             3
 wabt/execute/micro/spinner/1_mean                               +44.1612        +44.1605             0             2             0             2
 wabt/execute/micro/spinner/1000_mean                             +1.8353         +1.8353            15            41            15            41

This does not look very impressive.

wabt::interp::DefinedModule* m_module{nullptr};

// WABT Executor/Thread with default options.
wabt::interp::Executor m_executor{&m_env};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previously the stack space was allocated here. Not allocating stack for every call had big impact on performance.

})()};
wabt::interp::Module::Ptr m_module;
wabt::interp::Instance::Ptr m_instance;
wabt::interp::Thread::Ptr m_thread{wabt::interp::Thread::New(m_store, {})};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Default values are fine provided we create it once.

Copy link
Member

Choose a reason for hiding this comment

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

So m_store does not need to be mutable anymore, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

So m_store does not need to be mutable anymore, right?

It still needs it for get_memory where it gets the (smart) pointer to memory, which can be only non-const.

@chfast
Copy link
Collaborator Author

chfast commented Sep 16, 2020

I benchmarked the version with Thread preallocation, but it changes little. The Thread allocation saves ~2 µs so it affects mostly micro-benchmarks.

Copy link
Collaborator Author

@chfast chfast left a comment

Choose a reason for hiding this comment

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

Approved.

@axic
Copy link
Member

axic commented Sep 17, 2020

Make sure to squash the last commit :)

@gumb0
Copy link
Collaborator

gumb0 commented Sep 17, 2020

I've got similar or worse results

 wabt/parse/blake2b_mean                                          -0.0195         -0.0202           149           146           149           146
 wabt/instantiate/blake2b_mean                                    +0.0806         +0.0807           158           171           158           171
 wabt/execute/blake2b/512_bytes_rounds_1_mean                     +3.0988         +3.1005           243           995           243           996
 wabt/execute/blake2b/512_bytes_rounds_16_mean                    +3.1907         +3.1922          3640         15254          3640         15260
 wabt/parse/ecpairing_mean                                        +0.0178         +0.0181          8392          8541          8392          8544
 wabt/instantiate/ecpairing_mean                                  +0.0387         +0.0390          8428          8754          8428          8756
 wabt/execute/ecpairing/onepoint_mean                             +3.0752         +3.0756       1114023       4539822       1114017       4540296
 wabt/parse/keccak256_mean                                        +0.0113         +0.0117           247           250           247           250
 wabt/instantiate/keccak256_mean                                  +0.1028         +0.1026           251           276           250           276
 wabt/execute/keccak256/512_bytes_rounds_1_mean                   +2.9105         +2.9107           237           926           237           926
 wabt/execute/keccak256/512_bytes_rounds_16_mean                  +2.9136         +2.9132          3480         13620          3479         13615
 wabt/parse/memset_mean                                           -0.1130         -0.1131            38            33            38            33
 wabt/instantiate/memset_mean                                     +0.2092         +0.2091            46            56            46            56
 wabt/execute/memset/256_bytes_mean                               +2.5077         +2.5075            21            72            21            72
 wabt/execute/memset/60000_bytes_mean                             +2.4606         +2.4603          4535         15695          4535         15691
 wabt/parse/mul256_opt0_mean                                      -0.1235         -0.1236            49            43            49            43
 wabt/instantiate/mul256_opt0_mean                                +0.0473         +0.0473            56            58            56            58
 wabt/execute/mul256_opt0/input0_mean                             +3.3520         +3.3518            79           344            79           344
 wabt/execute/mul256_opt0/input1_mean                             +3.3580         +3.3578            79           344            79           344
 wabt/parse/ramanujan_pi_mean                                     -0.0382         -0.0383           135           130           135           130
 wabt/instantiate/ramanujan_pi_mean                               +0.0804         +0.0804           141           153           141           153
 wabt/execute/ramanujan_pi/33_runs_mean                           +3.0658         +3.0658           325          1321           325          1321
 wabt/parse/sha1_mean                                             -0.0158         -0.0158           233           229           233           229
 wabt/instantiate/sha1_mean                                       +0.0663         +0.0663           237           252           237           252
 wabt/execute/sha1/512_bytes_rounds_1_mean                        +3.1111         +3.1111           269          1104           268          1104
 wabt/execute/sha1/512_bytes_rounds_16_mean                       +3.1225         +3.1225          3755         15478          3754         15477
 wabt/parse/sha256_mean                                           -0.0251         -0.0252           404           394           404           394
 wabt/instantiate/sha256_mean                                     +0.0205         +0.0205           411           419           411           419
 wabt/execute/sha256/512_bytes_rounds_1_mean                      +3.0870         +3.0869           252          1031           252          1031
 wabt/execute/sha256/512_bytes_rounds_16_mean                     +3.1396         +3.1395          3467         14354          3467         14353
 wabt/parse/taylor_pi_mean                                        -0.3111         -0.3111            18            13            18            13
 wabt/instantiate/taylor_pi_mean                                  +0.2083         +0.2083            26            31            26            31
 wabt/execute/taylor_pi/pi_1000000_runs_mean                      +1.8767         +1.8767        123269        354604        123261        354589
 wabt/parse/micro/eli_interpreter_mean                            -0.1446         -0.1445            23            20            23            20
 wabt/instantiate/micro/eli_interpreter_mean                      +0.2448         +0.2450            31            39            31            39
 wabt/execute/micro/eli_interpreter/halt_mean                     +1.1912         +1.1913             0             0             0             0
 wabt/execute/micro/eli_interpreter/exec105_mean                +160.7358       +160.7402             0            37             0            37
 wabt/parse/micro/factorial_mean                                  -0.0482         -0.0482             4             4             4             4
 wabt/instantiate/micro/factorial_mean                            +0.5623         +0.5624             4             6             4             6
 wabt/execute/micro/factorial/10_mean                             +2.1454         +2.1455             1             2             1             2
 wabt/execute/micro/factorial/20_mean                             +2.2646         +2.2647             1             4             1             4
 wabt/parse/micro/fibonacci_mean                                  -0.0174         -0.0174             6             5             6             5
 wabt/instantiate/micro/fibonacci_mean                            +0.5004         +0.5005             5             8             5             8
 wabt/execute/micro/fibonacci/24_mean                             +2.4647         +2.4648         10801         37422         10800         37420
 wabt/parse/micro/host_adler32_mean                               -0.2609         -0.2608             9             7             9             7
 wabt/instantiate/micro/host_adler32_mean                         +0.2724         +0.2725            13            17            13            17
 wabt/execute/micro/host_adler32/1_mean                           -0.8320         -0.8320             4             1             4             1
 wabt/execute/micro/host_adler32/100_mean                         -0.8958         -0.8958           348            36           348            36
 wabt/execute/micro/host_adler32/1000_mean                        -0.9002         -0.9002          3495           349          3494           349
 wabt/parse/micro/spinner_mean                                    -0.1024         -0.1024             4             3             4             3
 wabt/instantiate/micro/spinner_mean                              +0.6440         +0.6441             3             6             3             6
 wabt/execute/micro/spinner/1_mean                                +1.2754         +1.2755             0             0             0             0
 wabt/execute/micro/spinner/1000_mean                             +2.1001         +2.1002            25            79            25            79

@chfast
Copy link
Collaborator Author

chfast commented Sep 17, 2020

I propose to merge it as is, and report upstream. Depending on the feedback we may adjust to code in following PRs.

@chfast chfast force-pushed the upgrade_wabt branch 2 times, most recently from f966f6c to 33f5554 Compare September 25, 2020 09:32
@chfast chfast changed the title Upgrade wabt Upgrade WABT to 1.0.19 Sep 25, 2020
@chfast
Copy link
Collaborator Author

chfast commented Sep 25, 2020

Updated benchmarks, now without -fPIC (not needed because wasm.so is not built).

 wabt/parse/blake2b_mean                                          -0.0409         -0.0409            72            70            72            70
 wabt/instantiate/blake2b_mean                                    +0.0712         +0.0712            78            84            78            84
 wabt/execute/blake2b/512_bytes_rounds_1_mean                     +1.9298         +1.9297           154           452           154           452
 wabt/execute/blake2b/512_bytes_rounds_16_mean                    +1.9391         +1.9389          2356          6924          2356          6924
 wabt/parse/ecpairing_mean                                        -0.0030         -0.0031          4115          4103          4115          4103
 wabt/instantiate/ecpairing_mean                                  +0.0336         +0.0336          4148          4287          4147          4287
 wabt/execute/ecpairing/onepoint_mean                             +1.9303         +1.9302        720502       2111302        720507       2111217
 wabt/parse/keccak256_mean                                        -0.0083         -0.0082           120           119           120           119
 wabt/instantiate/keccak256_mean                                  +0.1017         +0.1017           123           136           123           136
 wabt/execute/keccak256/512_bytes_rounds_1_mean                   +1.5022         +1.5024           173           432           173           432
 wabt/execute/keccak256/512_bytes_rounds_16_mean                  +1.5100         +1.5101          2543          6383          2543          6384
 wabt/parse/memset_mean                                           -0.1467         -0.1466            19            16            19            16
 wabt/instantiate/memset_mean                                     +0.1527         +0.1527            23            27            23            27
 wabt/execute/memset/256_bytes_mean                               +2.1542         +2.1543            11            36            11            36
 wabt/execute/memset/60000_bytes_mean                             +2.1705         +2.1705          2521          7992          2521          7993
 wabt/parse/mul256_opt0_mean                                      -0.1455         -0.1455            24            21            24            21
 wabt/instantiate/mul256_opt0_mean                                +0.1140         +0.1140            27            30            27            30
 wabt/execute/mul256_opt0/input0_mean                             +2.4899         +2.4899            44           155            44           155
 wabt/execute/mul256_opt0/input1_mean                             +2.4910         +2.4910            45           155            45           155
 wabt/parse/ramanujan_pi_mean                                     -0.0420         -0.0420            65            62            65            62
 wabt/instantiate/ramanujan_pi_mean                               +0.0889         +0.0889            68            74            68            74
 wabt/execute/ramanujan_pi/33_runs_mean                           +1.8442         +1.8441           237           673           237           673
 wabt/parse/sha1_mean                                             -0.0231         -0.0231           113           110           113           110
 wabt/instantiate/sha1_mean                                       +0.0591         +0.0591           116           123           116           123
 wabt/execute/sha1/512_bytes_rounds_1_mean                        +2.1333         +2.1332           174           544           174           544
 wabt/execute/sha1/512_bytes_rounds_16_mean                       +2.1642         +2.1641          2415          7641          2415          7641
 wabt/parse/sha256_mean                                           -0.0237         -0.0238           198           193           198           193
 wabt/instantiate/sha256_mean                                     +0.0400         +0.0400           202           210           202           210
 wabt/execute/sha256/512_bytes_rounds_1_mean                      +1.7065         +1.7064           188           510           188           510
 wabt/execute/sha256/512_bytes_rounds_16_mean                     +1.7403         +1.7402          2599          7123          2599          7123
 wabt/parse/taylor_pi_mean                                        -0.3649         -0.3650             9             6             9             6
 wabt/instantiate/taylor_pi_mean                                  +0.0986         +0.0986            14            16            14            16
 wabt/execute/taylor_pi/pi_1000000_runs_mean                      +1.7437         +1.7436         70885        194487         70885        194481
 wabt/parse/micro/eli_interpreter_mean                            -0.2214         -0.2214            12             9            12             9
 wabt/instantiate/micro/eli_interpreter_mean                      +0.1220         +0.1220            16            18            16            18
 wabt/execute/micro/eli_interpreter/halt_mean                     +0.9112         +0.9112             0             0             0             0
 wabt/execute/micro/eli_interpreter/exec105_mean                +150.8334       +150.8263             0            19             0            19
 wabt/parse/micro/factorial_mean                                  -0.0959         -0.0959             2             2             2             2
 wabt/instantiate/micro/factorial_mean                            +0.4774         +0.4773             2             3             2             3
 wabt/execute/micro/factorial/10_mean                             +1.8356         +1.8355             0             1             0             1
 wabt/execute/micro/factorial/20_mean                             +1.9805         +1.9804             1             2             1             2
 wabt/parse/micro/fibonacci_mean                                  -0.0643         -0.0642             3             3             3             3
 wabt/instantiate/micro/fibonacci_mean                            +0.4012         +0.4013             3             4             3             4
 wabt/execute/micro/fibonacci/24_mean                             +2.1453         +2.1454          5812         18279          5812         18280
 wabt/parse/micro/host_adler32_mean                               -0.3032         -0.3032             5             3             5             3
 wabt/instantiate/micro/host_adler32_mean                         +0.1361         +0.1361             7             8             7             8
 wabt/execute/micro/host_adler32/1_mean                           -0.8747         -0.8747             2             0             2             0
 wabt/execute/micro/host_adler32/100_mean                         -0.9290         -0.9290           219            16           219            16
 wabt/execute/micro/host_adler32/1000_mean                        -0.9292         -0.9292          2184           155          2184           155
 wabt/parse/micro/spinner_mean                                    -0.1185         -0.1185             2             2             2             2
 wabt/instantiate/micro/spinner_mean                              +0.5397         +0.5397             2             3             2             3
 wabt/execute/micro/spinner/1_mean                                +0.9698         +0.9698             0             0             0             0
 wabt/execute/micro/spinner/1000_mean                             +1.7462         +1.7462            15            40            15            40

@gumb0 gumb0 mentioned this pull request Sep 28, 2020
@gumb0 gumb0 merged commit 8c28890 into master Sep 28, 2020
@gumb0 gumb0 deleted the upgrade_wabt branch September 28, 2020 17:19
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