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

Optimize for common drop_keep cases in wasmi executor #493

Merged
merged 3 commits into from
Oct 4, 2022

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Oct 2, 2022

This is a result of an observation that we could speed-up execution of branch and return instructions that keep no values or just a single value upon jump. Especially in the Wasm MVP those two cases are the common ones.

This is take 2 after the first experiment yielded really bad results: #492

@Robbepop Robbepop marked this pull request as ready for review October 2, 2022 18:40
@Robbepop
Copy link
Member Author

Robbepop commented Oct 2, 2022

On my local machine I am observing speed ups up to 10% especially for call intense workloads. Unfortunately our benchmarking CI cannot confirm this right now.

@Robbepop Robbepop changed the title [WIP] Optimize jumps that keep zero elements on the stack (take 2) Optimize jumps that keep zero elements on the stack (take 2) Oct 2, 2022
@Robbepop Robbepop changed the title Optimize jumps that keep zero elements on the stack (take 2) Optimize for common drop_keep cases in wasmi executor Oct 2, 2022
@paritytech-cicd-pr
Copy link

paritytech-cicd-pr commented Oct 3, 2022

BENCHMARKS

NATIVEWASMTIME
BENCHMARKMASTERPRDIFFMASTERPRDIFFWASMTIME OVERHEAD
execute/
count_until
2.36ms 2.19ms 🟢 -8.36% 9.20ms 9.36ms 🔴 1.82% 🔴 327%
execute/
factorial_iterative
1.52µs 1.66µs 🔴 9.41% 3.34µs 3.32µs ⚪ -0.58% 🟡 100%
execute/
factorial_recursive
2.10µs 2.12µs ⚪ 0.80% 4.13µs 4.16µs ⚪ 0.58% 🟡 96%
execute/
fib_iterative
10.58ms 10.04ms 🟢 -5.24% 15.62ms 15.56ms ⚪ -0.24% 🟡 55%
execute/
fib_recursive
17.20ms 19.00ms 🔴 10.86% 39.47ms 38.74ms 🟢 -1.87% 🔴 104%
execute/
global_bump
3.50ms 3.64ms 🔴 4.89% 12.73ms 13.39ms 🔴 4.89% 🔴 268%
execute/
host_calls
33.07µs 33.54µs ⚪ 0.05% 108.36µs 106.68µs 🟢 -1.41% 🔴 218%
execute/
memory_fill
8.19ms 8.61ms 🔴 5.18% 14.75ms 14.82ms ⚪ 0.55% 🟡 72%
execute/
memory_sum
8.28ms 7.91ms 🟢 -5.41% 15.15ms 14.99ms 🟢 -1.14% 🟡 89%
execute/
memory_vec_add
14.79ms 15.14ms 🔴 2.39% 30.11ms 30.36ms ⚪ 0.92% 🟡 100%
execute/
recursive_is_even
2.69ms 2.75ms 🔴 2.13% 6.65ms 6.62ms ⚪ -0.33% 🔴 141%
execute/
recursive_ok
369.29µs 416.49µs 🔴 12.64% 924.43µs 916.21µs ⚪ -0.72% 🔴 120%
execute/
recursive_scan
476.63µs 488.60µs 🔴 2.63% 1.30ms 1.30ms ⚪ 0.33% 🔴 167%
execute/
recursive_trap
37.21µs 43.73µs 🔴 17.78% 96.06µs 97.76µs 🔴 1.85% 🔴 124%
execute/
regex_redux
3.36ms 3.44ms 🔴 2.38% 5.12ms 5.07ms ⚪ -0.80% 🟢 48%
execute/
rev_complement
3.06ms 3.13ms 🔴 2.46% 4.95ms 4.96ms ⚪ 0.23% 🟡 58%
execute/
tiny_keccak
2.62ms 2.63ms ⚪ 0.60% 4.14ms 4.17ms ⚪ 0.61% 🟡 58%
execute/
trunc_f2i
3.51ms 3.60ms 🔴 2.64% 8.97ms 9.12ms 🔴 1.59% 🔴 153%
instantiate/
wasm_kernel
76.87µs 78.16µs 🔴 1.68% 136.80µs 103.29µs 🟢 -24.44% 🟢 32%
translate/
wasm_kernel
6.27ms 6.09ms ⚪ -1.10% 11.77ms 11.77ms ⚪ 0.05% 🟡 93%

Link to pipeline

@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2022

Codecov Report

Merging #493 (967fdb8) into master (1fbc2d3) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #493      +/-   ##
==========================================
+ Coverage   79.18%   79.20%   +0.01%     
==========================================
  Files          74       74              
  Lines        6309     6314       +5     
==========================================
+ Hits         4996     5001       +5     
  Misses       1313     1313              
Impacted Files Coverage Δ
crates/wasmi/src/engine/executor.rs 98.27% <100.00%> (+<0.01%) ⬆️
crates/wasmi/src/engine/stack/values/vref.rs 98.52% <100.00%> (+0.09%) ⬆️

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

The procedures to keep values is pretty expensive when in the case where no values shall be kept so we bail out early for some nice and easy performance gains in some cases.
@Robbepop Robbepop force-pushed the rf-optimize-branch-dropkeep-v2 branch from 967fdb8 to edcd580 Compare October 4, 2022 09:28
@Robbepop Robbepop merged commit bdac479 into master Oct 4, 2022
@Robbepop Robbepop deleted the rf-optimize-branch-dropkeep-v2 branch October 4, 2022 10:35
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