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

wasmi_v1: improve instruction scheduler #376

Merged
merged 11 commits into from
Jul 13, 2022

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Jul 11, 2022

This PR changes the instruction scheduler of the wasmi_v1 engine.
The new approach seems promising and also is less affected by the performance regressions with newer rustc versions than the current interpreter instruction scheduler.
Note that the instruction scheduler is on the absolute hot path of the interpreter which is why we see significant changes in performance.

We compare the performance of Rust 1.59 because that is the last version before the performance regressions and we also use Rust 1.62 because it is the current stable Rust version.

Rust 1.59

Test Before After Change
tiny_keccak 970.77 793.95 µs -17.890%
rev_complement 1.1200 991.54 µs -11.326%
regex_redux 1.1962 1.0809 ms -9.5504%
count_until 1.7180 1.4201 ms -17.382%
factorial_recursive 1.1851 1.1655 µs -1.6003%
factorial_optimized 740.47 635.99 ns -13.924%
recursive_ok 312.90 304.17 µs -3.2702%
recursive_trap 28.212 27.951 µs -0.8383%
host_calls 45.054 43.287 µs -3.7734%
fib_recursive 12.633 13.025 ms +3.0991%

Rust 1.62 (Stable)

Test Before After Change
tiny_keccak 1.4818 ms 916.57 µs -36.988%
rev_complement 1.4554 ms 1.1097 ms -23.228%
regex_redux 1.4766 ms 1.1896 ms -19.362%
count_until 2.2027 ms 1.6776 ms -23.720%
factorial_recursive 1.4349 µs 1.2398 µs -14.031%
factorial_optimized 935.66 ns 719.33 ns -23.144%
recursive_ok 354.32 µs 322.68 µs -8.6313%
recursive_trap 33.905 µs 29.536 µs -12.983%
host_calls 53.669 µs 49.136 µs -8.5481%
fib_recursive 15.320 ms 13.496 ms -11.907%

Conclusion

All in all a significant improvement across the board. However, even the new instruction scheduler still suffers a performance degradation of roughly 15-20% with a newer rustc version compared to Rust 1.59.

@codecov-commenter
Copy link

codecov-commenter commented Jul 11, 2022

Codecov Report

Merging #376 (ef3be2a) into master (6133346) will decrease coverage by 0.07%.
The diff coverage is 99.07%.

❗ Current head ef3be2a differs from pull request most recent head 3aaff64. Consider uploading reports for the commit 3aaff64 to get more accurate results

@@            Coverage Diff             @@
##           master     #376      +/-   ##
==========================================
- Coverage   79.39%   79.31%   -0.08%     
==========================================
  Files          97       98       +1     
  Lines       11187    11197      +10     
==========================================
- Hits         8882     8881       -1     
- Misses       2305     2316      +11     
Impacted Files Coverage Δ
wasmi_v1/src/engine/bytecode/mod.rs 100.00% <ø> (ø)
wasmi_v1/src/engine/bytecode/utils.rs 68.29% <ø> (-10.96%) ⬇️
wasmi_v1/src/engine/code_map.rs 57.62% <66.66%> (-30.81%) ⬇️
wasmi_v1/src/engine/exec_context.rs 97.64% <99.29%> (+1.20%) ⬆️
wasmi_v1/src/engine/call_stack.rs 80.64% <100.00%> (+1.33%) ⬆️
wasmi_v1/src/engine/mod.rs 85.18% <100.00%> (ø)
src/module.rs 73.58% <0.00%> (-0.63%) ⬇️
benches/wasm/wasm_kernel/src/rev_complement.rs 0.00% <0.00%> (ø)
src/runner.rs 92.44% <0.00%> (+0.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6133346...3aaff64. Read the comment docs.

@Robbepop Robbepop force-pushed the rf-v1-improve-instruction-scheduler branch from 3aaff64 to 20867a6 Compare July 12, 2022 22:11
@Robbepop Robbepop marked this pull request as ready for review July 13, 2022 15:02
@Robbepop Robbepop changed the title [WIP] v1: improve instruction scheduler wasmi_v1: improve instruction scheduler Jul 13, 2022
@Robbepop Robbepop merged commit f5d8f7c into master Jul 13, 2022
@Robbepop Robbepop mentioned this pull request Jul 13, 2022
4 tasks
@Robbepop
Copy link
Member Author

Note that this PR also fixes this rustc issue in parts since the new instruction dispatcher is no longer as heavily affected by the rustc performance regressions as was the case with the previous (old) instruction dispatcher. Between Rust 1.59 and Rust 1.62 (current stable) the old instruction dispatcher regressed by roughly 50-60% in performance according to our benchmarks whereas the new instruction dispatcher is "only" regressed by roughly 20%. Still 20% is a lot though ...

@athei athei deleted the rf-v1-improve-instruction-scheduler branch July 26, 2022 10:43
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.

2 participants