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

Make branch instructions offset program counter by delta (PR) #478

Merged
merged 15 commits into from
Sep 27, 2022

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Sep 27, 2022

Implements #473.

This PR also introduces the LabelRegistry abstraction that helps build up BranchParams during compilation of a Wasm program lazily. The new LabelRegistry makes it possible to reuse more heap allocated memory than was possible before for some significant speedups in the range of 5-6%.

Merging this PR will allow us to improve and optimize the wasmi bytecode executor instruction pointer.

We have not yet introduced an actual difference between them in this commit.
Also rename
- BranchParams::destination_pc -> target
- BranchParams::update_destination_pc -> update_target
This makes Instruction again a non-generic type.
Label users are now stored again but in a single Vec to allow for proper heap memory reuse.
Branch targets are now branch offsets since that is going to support a single instruction pointer design in the future.
@Robbepop Robbepop changed the title Rf branch by delta Make branch instructions offset program counter by delta (PR) Sep 27, 2022
@paritytech-cicd-pr
Copy link

paritytech-cicd-pr commented Sep 27, 2022

CRITERION BENCHMARKS

BENCHMARK MASTER PR Diff
execute/count_until 2.9869 ms 2.0834 ms 🟢 -30.2877 %
execute/factorial_iterative 1.6852 µs 1.4352 µs 🟢 -14.7267 %
execute/factorial_recursive 2.1872 µs 2.2381 µs 🔴 +2.4623 %
execute/fib_iterative 10.1064 ms 9.4443 ms 🟢 -5.5977 %
execute/fib_recursive 19.3727 ms 20.2258 ms 🔴 +4.0821 %
execute/global_bump 3.8568 ms 3.9011 ms 🔴 +1.1847 %
execute/host_calls 35.1847 µs 35.2119 µs ⚪ +0.0937 %
execute/memory_fill 9.6104 ms 9.464 ms 🟢 -1.5326 %
execute/memory_sum 8.9388 ms 9.1458 ms 🔴 +2.2346 %
execute/memory_vec_add 16.3352 ms 16.0494 ms 🟢 -1.7625 %
execute/recursive_is_even 3.0453 ms 3.4298 ms 🔴 +12.8158 %
execute/recursive_ok 402.6154 µs 405.192 µs ⚪ +0.8194 %
execute/recursive_scan 511.8727 µs 527.8285 µs 🔴 +3.3084 %
execute/recursive_trap 39.5421 µs 38.7193 µs 🟢 -1.9397 %
execute/regex_redux 3.515 ms 3.5176 ms ⚪ +0.1921 %
execute/rev_complement 3.1142 ms 3.1516 ms 🔴 +1.1625 %
execute/tiny_keccak 2.6718 ms 2.6652 ms ⚪ -0.3952 %
execute/trunc_f2i 3.7365 ms 3.7093 ms ⚪ -0.719 %
instantiate/wasm_kernel 78.1051 µs 78.0839 µs ⚪ +0.0345 %
translate/wasm_kernel 6.4006 ms 6.1372 ms 🟢 -4.1014 %

Link to pipeline

@codecov-commenter
Copy link

Codecov Report

Merging #478 (b2d609a) into master (5ce1d4f) will increase coverage by 0.08%.
The diff coverage is 86.88%.

@@            Coverage Diff             @@
##           master     #478      +/-   ##
==========================================
+ Coverage   79.15%   79.24%   +0.08%     
==========================================
  Files          73       74       +1     
  Lines        6255     6296      +41     
==========================================
+ Hits         4951     4989      +38     
- Misses       1304     1307       +3     
Impacted Files Coverage Δ
crates/wasmi/src/engine/bytecode/tests.rs 100.00% <ø> (ø)
crates/wasmi/src/engine/mod.rs 83.49% <ø> (ø)
crates/wasmi/src/engine/func_builder/labels.rs 70.90% <70.90%> (ø)
...ates/wasmi/src/engine/func_builder/inst_builder.rs 78.43% <78.78%> (+4.51%) ⬆️
crates/wasmi/src/engine/bytecode/utils.rs 76.27% <95.45%> (+7.52%) ⬆️
crates/wasmi/src/engine/bytecode/mod.rs 100.00% <100.00%> (ø)
crates/wasmi/src/engine/executor.rs 98.41% <100.00%> (ø)
...tes/wasmi/src/engine/func_builder/control_frame.rs 90.00% <100.00%> (ø)
crates/wasmi/src/engine/func_builder/mod.rs 89.43% <100.00%> (+0.52%) ⬆️
crates/wasmi/src/module/tests.rs 98.66% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Robbepop Robbepop merged commit 67d98bc into master Sep 27, 2022
@Robbepop Robbepop deleted the rf-branch-by-delta branch September 27, 2022 21:40
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