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

Implement Wasm tail-call proposal #683

Merged
merged 30 commits into from
Mar 1, 2023
Merged

Implement Wasm tail-call proposal #683

merged 30 commits into from
Mar 1, 2023

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Feb 16, 2023

Closes #363.

  • Passes 100% of the official Wasm spec testsuite.
  • Fix interoperability bug with resumable calls.
    • Since resumable calls expect a frame on the call stack upon call resumption we cannot do a proper tail call when calling host functions in a resumable call mode.

Benchmarks show that for example tail recursive fibonacci is pretty efficient. While it is less efficient than iterative fibonacci it is miles and miles ahead of non-tail recursive fibonacci. Ideally we had more benchmarks. Tested with N = 100_000.

grafik

@paritytech-cicd-pr
Copy link

paritytech-cicd-pr commented Feb 16, 2023

BENCHMARKS

NATIVEWASMTIME
BENCHMARKMASTERPRDIFFMASTERPRDIFFWASMTIME OVERHEAD
execute/
bare_call_0
1.51ms 1.89ms 🔴 25.47% 1.29ms 1.47ms 🔴 13.91% 🟢 -22%
execute/
bare_call_0/typed
1.14ms 1.12ms 🟢 -2.13% 919.37µs 952.44µs 🔴 3.58% 🟢 -15%
execute/
bare_call_1
1.56ms 1.85ms 🔴 19.40% 1.38ms 1.52ms 🔴 9.99% 🟢 -18%
execute/
bare_call_16
2.54ms 2.67ms 🔴 5.21% 3.34ms 3.30ms 🟢 -1.25% 🟢 23%
execute/
bare_call_16/typed
1.81ms 1.88ms 🔴 3.89% 1.56ms 1.57ms ⚪ 0.54% 🟢 -17%
execute/
bare_call_1/typed
1.22ms 1.23ms ⚪ 0.61% 1.19ms 1.24ms 🔴 4.13% 🟢 1%
execute/
bare_call_4
1.74ms 1.77ms 🔴 2.47% 1.77ms 1.77ms 🟢 0.13% 🟢 -0%
execute/
bare_call_4/typed
1.30ms 1.27ms ⚪ -0.83% 1.22ms 1.17ms 🟢 -4.36% 🟢 -8%
execute/
br_table
1.32ms 1.29ms 🟢 -2.85% 1.36ms 1.43ms 🔴 4.89% 🟢 11%
execute/
count_until
677.45µs 635.85µs 🟢 -6.28% 1.13ms 1.11ms 🟢 -1.78% 🟡 74%
execute/
factorial_iterative
343.74µs 332.29µs 🟢 -3.47% 476.07µs 485.22µs 🔴 1.88% 🟢 46%
execute/
factorial_recursive
591.79µs 592.66µs ⚪ 0.12% 908.54µs 1.08ms 🔴 18.65% 🟡 82%
execute/
fibonacci_iter
1.47ms 1.47ms ⚪ 0.32% 2.23ms 2.06ms 🟢 -7.29% 🟢 40%
execute/
fibonacci_rec
5.33ms 4.83ms 🟢 -9.61% 8.07ms 7.99ms ⚪ -0.97% 🟡 66%
execute/
fibonacci_tail
1.48ms 1.17ms 🟢 -20.80% 1.96ms 1.70ms 🟢 -13.27% 🟢 45%
execute/
global_bump
818.60µs 824.69µs ⚪ 0.79% 1.56ms 1.56ms ⚪ 0.06% 🟡 90%
execute/
global_const
754.19µs 716.48µs 🟢 -4.96% 1.43ms 1.39ms 🟢 -2.44% 🟡 94%
execute/
host_calls
31.25µs 35.96µs 🔴 15.57% 46.38µs 47.49µs 🔴 2.33% 🟢 32%
execute/
memory_fill
1.20ms 1.21ms ⚪ 0.76% 1.94ms 1.77ms 🟢 -8.32% 🟢 46%
execute/
memory_sum
1.19ms 1.19ms ⚪ -0.44% 1.93ms 1.85ms 🟢 -4.27% 🟡 56%
execute/
memory_vec_add
2.38ms 2.38ms ⚪ -0.06% 4.58ms 4.66ms 🔴 1.84% 🟡 96%
execute/
recursive_is_even
999.76µs 1.05ms 🔴 4.63% 1.67ms 1.65ms ⚪ -0.91% 🟡 58%
execute/
recursive_ok
122.97µs 122.06µs ⚪ -0.72% 202.14µs 200.55µs ⚪ -0.76% 🟡 64%
execute/
recursive_scan
158.39µs 156.82µs ⚪ -0.96% 260.87µs 250.00µs 🟢 -3.81% 🟡 59%
execute/
recursive_trap
12.50µs 12.59µs ⚪ 0.25% 21.52µs 20.82µs 🟢 -3.36% 🟡 65%
execute/
regex_redux
521.92µs 518.59µs ⚪ -0.72% 913.04µs 916.05µs ⚪ 0.27% 🟡 77%
execute/
rev_complement
465.14µs 458.00µs ⚪ -1.26% 775.23µs 776.19µs ⚪ 0.07% 🟡 69%
execute/
tiny_keccak
331.67µs 330.80µs ⚪ 0.05% 603.16µs 576.31µs 🟢 -4.30% 🟡 74%
execute/
trunc_f2i
775.88µs 786.44µs 🔴 1.36% 1.40ms 1.38ms 🟢 -1.82% 🟡 76%
instantiate/
wasm_kernel
54.50µs 54.19µs ⚪ -1.49% 53.65µs 54.89µs ⚪ -0.32% 🟢 1%
translate/
erc1155
235.69µs 233.39µs ⚪ -1.06% 441.79µs 428.99µs 🟢 -2.93% 🟡 84%
translate/
erc20
114.17µs 113.34µs ⚪ -0.60% 212.64µs 207.07µs 🟢 -2.62% 🟡 83%
translate/
erc721
160.71µs 162.21µs ⚪ 0.61% 310.43µs 300.98µs 🟢 -3.04% 🟡 86%
translate/
spidermonkey
0.00ns 0.00ns 🔴 1.50% 0.00ns 0.00ns 🟢 -3.80% 🟢 0%
translate/
wasm_kernel
4.07ms 4.05ms ⚪ -0.61% 8.25ms 7.96ms 🟢 -3.42% 🟡 96%

Link to pipeline

@Robbepop Robbepop merged commit aecf008 into master Mar 1, 2023
@Robbepop Robbepop deleted the rf-wasm-tail-calls branch March 1, 2023 10:16
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.

Implement Wasm proposal: tail-call
2 participants