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

Add support for Linker defined host functions #692

Merged
merged 7 commits into from
Mar 1, 2023
Merged

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Feb 24, 2023

Closes #663.

cc @flavio

Todo

  • Add tests for Linker::func_new and Linker::func_wrap.

@paritytech-cicd-pr
Copy link

paritytech-cicd-pr commented Feb 24, 2023

BENCHMARKS

NATIVEWASMTIME
BENCHMARKMASTERPRDIFFMASTERPRDIFFWASMTIME OVERHEAD
execute/
bare_call_0
1.51ms 1.51ms ⚪ 0.07% 1.46ms 1.37ms 🟢 -5.95% 🟢 -9%
execute/
bare_call_0/typed
1.11ms 1.12ms ⚪ 0.67% 954.89µs 956.23µs ⚪ 0.00% 🟢 -15%
execute/
bare_call_1
1.55ms 1.56ms 🔴 0.61% 1.48ms 1.45ms 🔴 -2.03% 🟢 -7%
execute/
bare_call_16
2.45ms 2.47ms 🔴 0.37% 3.31ms 3.44ms 🔴 3.98% 🟢 40%
execute/
bare_call_16/typed
1.75ms 1.82ms 🔴 3.85% 1.60ms 1.63ms 🔴 1.83% 🟢 -10%
execute/
bare_call_1/typed
1.22ms 1.23ms ⚪ 0.50% 1.31ms 1.24ms 🟢 -5.46% 🟢 0%
execute/
bare_call_4
1.72ms 1.74ms 🔴 1.41% 1.78ms 1.77ms 🔴 -0.22% 🟢 2%
execute/
bare_call_4/typed
1.27ms 1.31ms 🔴 3.36% 1.17ms 1.22ms 🔴 3.77% 🟢 -7%
execute/
br_table
1.30ms 1.31ms ⚪ 0.74% 1.41ms 1.39ms 🟢 -1.25% 🟢 6%
execute/
count_until
718.03µs 680.67µs 🟢 -5.12% 1.10ms 989.99µs 🟢 -9.90% 🟢 45%
execute/
factorial_iterative
368.86µs 332.49µs 🟢 -9.68% 485.66µs 433.91µs 🟢 -10.51% 🟢 31%
execute/
factorial_recursive
595.35µs 588.22µs ⚪ -1.03% 900.61µs 883.16µs 🟢 -1.72% 🟢 50%
execute/
fibonacci_iter
1.47ms 1.47ms ⚪ -0.47% 2.06ms 2.06ms ⚪ -0.11% 🟢 40%
execute/
fibonacci_rec
4.83ms 4.77ms ⚪ -1.19% 8.35ms 7.23ms 🟢 -13.44% 🟡 52%
execute/
fibonacci_tail
1.22ms 1.18ms 🟢 -3.83% 1.77ms 1.56ms 🟢 -12.41% 🟢 32%
execute/
global_bump
798.70µs 786.86µs ⚪ -1.13% 1.56ms 1.32ms 🟢 -15.23% 🟡 68%
execute/
global_const
812.12µs 718.80µs 🟢 -11.44% 1.39ms 1.17ms 🟢 -15.55% 🟡 63%
execute/
host_calls
35.64µs 35.92µs ⚪ 0.72% 47.01µs 48.86µs 🔴 4.04% 🟢 36%
execute/
memory_fill
1.21ms 1.20ms ⚪ -1.33% 1.78ms 1.74ms 🟢 -2.61% 🟢 45%
execute/
memory_sum
1.19ms 1.19ms ⚪ -0.06% 1.85ms 1.76ms 🟢 -4.87% 🟢 49%
execute/
memory_vec_add
2.38ms 2.40ms ⚪ 0.62% 4.66ms 3.88ms 🟢 -16.62% 🟡 62%
execute/
recursive_is_even
1.04ms 1.05ms ⚪ 0.65% 1.67ms 1.75ms 🔴 5.01% 🟡 67%
execute/
recursive_ok
123.45µs 120.86µs 🟢 -2.28% 203.38µs 204.13µs ⚪ 0.11% 🟡 69%
execute/
recursive_scan
161.16µs 157.27µs ⚪ -2.00% 261.91µs 252.97µs 🟢 -3.51% 🟡 61%
execute/
recursive_trap
12.53µs 12.34µs 🟢 -1.47% 20.92µs 22.50µs 🔴 7.44% 🟡 82%
execute/
regex_redux
500.23µs 498.97µs ⚪ -0.36% 898.08µs 841.09µs 🟢 -6.36% 🟡 69%
execute/
rev_complement
464.25µs 462.10µs ⚪ 0.32% 778.03µs 723.57µs 🟢 -7.03% 🟡 57%
execute/
tiny_keccak
325.60µs 324.37µs ⚪ -0.13% 575.63µs 546.44µs 🟢 -5.15% 🟡 68%
execute/
trunc_f2i
787.73µs 779.86µs ⚪ -0.97% 1.38ms 1.37ms ⚪ -1.01% 🟡 75%
instantiate/
wasm_kernel
56.32µs 54.06µs 🟢 -2.81% 58.80µs 55.35µs 🟢 -6.58% 🟢 2%
translate/
erc1155
234.79µs 234.79µs ⚪ -0.46% 432.97µs 440.45µs 🔴 1.75% 🟡 88%
translate/
erc20
113.75µs 114.06µs ⚪ 0.39% 210.39µs 212.22µs ⚪ 1.15% 🟡 86%
translate/
erc721
160.45µs 162.34µs ⚪ 0.79% 307.69µs 309.86µs ⚪ 0.88% 🟡 91%
translate/
spidermonkey
0.00ns 0.00ns 🔴 1.66% 0.00ns 0.00ns 🔴 1.56% 🟢 0%
translate/
wasm_kernel
4.04ms 4.10ms 🔴 1.56% 8.09ms 8.18ms ⚪ 1.09% 🟡 99%

Link to pipeline

@Robbepop
Copy link
Member Author

As of now I don't know where the double digit performance regressions in some native benchmarks are coming from. I can reproduce them locally. Will need some research about this before merging this PR. It is very weird since this PR does not even remotely touch the execution engine of wasmi.

@Robbepop
Copy link
Member Author

This PR in its current state is not mergeable due to the massive performance regressions on the Wasm target.

@Robbepop
Copy link
Member Author

Robbepop commented Mar 1, 2023

Performance regressions seems to be resolved with the most recent merge with master so we can finally merge this PR.

@Robbepop Robbepop merged commit 2a7d625 into master Mar 1, 2023
@Robbepop Robbepop deleted the rf-add-linker-funcs branch March 1, 2023 10:30
@flavio
Copy link

flavio commented Mar 1, 2023

Sweet, I'll update my wit-bindgen code to make use of it :)

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.

Add wasmi::Linker::func_wrap method
3 participants