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

Use references where possible in Store and StoreInner #634

Merged
merged 2 commits into from Jan 25, 2023

Conversation

Robbepop
Copy link
Collaborator

@Robbepop Robbepop commented Jan 25, 2023

The idea behind this change is that the Rust compiler (and LLVM) have a greater chance to apply optimizations if parameters are at most pointer sized. Unfortunately wasmi reference types such as Func, Global etc. do eventually not fit into a pointer and therefore might regress performance.

Furthermore this is more aligned with what the Wasmtime API does in such cases.
As an additional bonus this allows us to more room for experimentation with the internals of those wasmi reference types such as Func, Global etc. since wasmi methods are less dependent on the actual structure of those types with these changes.

@paritytech-cicd-pr
Copy link

paritytech-cicd-pr commented Jan 25, 2023

BENCHMARKS

NATIVEWASMTIME
BENCHMARKMASTERPRDIFFMASTERPRDIFFWASMTIME OVERHEAD
execute/
bare_call_0
1.40ms 1.52ms 🔴 8.52% 1.10ms 1.11ms ⚪ 1.32% 🟢 -27%
execute/
bare_call_0/typed
1.01ms 1.01ms ⚪ -0.61% 738.82µs 744.08µs ⚪ 0.62% 🟢 -26%
execute/
bare_call_1
1.44ms 1.47ms 🔴 2.39% 1.30ms 1.22ms 🟢 -6.17% 🟢 -17%
execute/
bare_call_16
2.42ms 2.40ms ⚪ -0.44% 4.21ms 4.20ms 🟢 -0.05% 🟡 75%
execute/
bare_call_16/typed
1.58ms 1.59ms ⚪ 0.74% 2.71ms 2.62ms 🟢 -3.37% 🟡 65%
execute/
bare_call_1/typed
1.10ms 1.10ms ⚪ -0.55% 1.09ms 1.06ms 🟢 -2.31% 🟢 -3%
execute/
bare_call_4
1.60ms 1.52ms 🔴 -5.09% 1.88ms 1.77ms 🔴 -5.96% 🟢 16%
execute/
bare_call_4/typed
1.11ms 1.14ms 🔴 2.66% 1.16ms 1.18ms 🔴 1.88% 🟢 4%
execute/
br_table
1.11ms 1.11ms ⚪ 0.45% 1.38ms 1.37ms ⚪ -0.34% 🟢 23%
execute/
count_until
711.33µs 651.62µs 🟢 -8.52% 2.78ms 2.37ms 🟢 -14.31% 🔴 263%
execute/
factorial_iterative
325.27µs 319.09µs 🟢 -1.74% 1.16ms 963.04µs 🟢 -17.00% 🔴 202%
execute/
factorial_recursive
645.56µs 629.57µs 🟢 -2.51% 1.64ms 1.25ms 🟢 -23.47% 🟡 98%
execute/
fib_iterative
1.43ms 1.41ms 🟢 -1.52% 6.01ms 5.53ms 🟢 -7.96% 🔴 292%
execute/
fib_recursive
5.68ms 5.67ms ⚪ -0.15% 14.61ms 10.76ms 🟢 -26.29% 🟡 90%
execute/
global_bump
1.02ms 952.91µs 🟢 -5.60% 3.79ms 2.63ms 🟢 -30.83% 🔴 176%
execute/
global_const
717.33µs 769.24µs 🔴 7.22% 3.26ms 2.80ms 🟢 -14.39% 🔴 264%
execute/
host_calls
28.85µs 26.09µs 🟢 -7.34% 43.21µs 36.14µs 🟢 -15.98% 🟢 39%
execute/
memory_fill
1.30ms 1.23ms 🟢 -5.76% 4.95ms 4.39ms 🟢 -11.35% 🔴 258%
execute/
memory_sum
1.25ms 1.17ms 🟢 -5.90% 4.97ms 4.39ms 🟢 -11.65% 🔴 274%
execute/
memory_vec_add
2.58ms 2.43ms 🟢 -5.76% 10.16ms 8.28ms 🟢 -18.36% 🔴 241%
execute/
recursive_is_even
1.16ms 1.14ms ⚪ -1.71% 2.91ms 2.31ms 🟢 -20.38% 🔴 103%
execute/
recursive_ok
148.65µs 146.67µs ⚪ -1.65% 383.49µs 323.16µs 🟢 -15.50% 🔴 120%
execute/
recursive_scan
179.85µs 180.68µs ⚪ 0.37% 488.80µs 387.54µs 🟢 -21.09% 🔴 114%
execute/
recursive_trap
14.41µs 13.86µs 🟢 -3.81% 39.82µs 29.05µs 🟢 -27.49% 🔴 110%
execute/
regex_redux
542.25µs 523.67µs 🟢 -3.46% 1.74ms 1.42ms 🟢 -18.30% 🔴 171%
execute/
rev_complement
501.75µs 478.43µs 🟢 -4.46% 1.69ms 1.47ms 🟢 -13.24% 🔴 207%
execute/
tiny_keccak
371.09µs 334.62µs 🟢 -9.76% 1.47ms 1.23ms 🟢 -16.25% 🔴 269%
execute/
trunc_f2i
909.20µs 696.49µs 🟢 -23.41% 2.85ms 2.14ms 🟢 -24.94% 🔴 207%
instantiate/
wasm_kernel
63.75µs 62.15µs ⚪ -2.27% 78.70µs 82.02µs 🔴 4.87% 🟢 32%
translate/
erc1155
207.41µs 206.65µs ⚪ -0.71% 392.11µs 375.90µs 🟢 -3.62% 🟡 82%
translate/
erc20
101.79µs 100.88µs ⚪ -1.23% 189.88µs 185.90µs 🟢 -2.64% 🟡 84%
translate/
erc721
146.11µs 145.27µs ⚪ -0.63% 276.42µs 276.26µs ⚪ 0.98% 🟡 90%
translate/
spidermonkey
0.00ns 0.00ns ⚪ 0.35% 0.00ns 0.00ns 🟢 -3.95% 🟢 0%
translate/
wasm_kernel
3.77ms 3.82ms ⚪ 0.18% 7.28ms 7.09ms 🟢 -2.59% 🟡 86%

Link to pipeline

@Robbepop Robbepop merged commit 77e574c into master Jan 25, 2023
@Robbepop Robbepop deleted the rf-use-store-refs branch January 25, 2023 11:29
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.

None yet

2 participants