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

Refactor, cleanup and optimize Wasm module instantiation #531

Merged
merged 13 commits into from
Oct 21, 2022

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Oct 21, 2022

  • Preallocates buffers upon Module instantiation to reduce amount of copying and reallocations.
  • Uses more dense data structures for Instance, e.g. Box<[T]> instead of Vec<T> or Box<str> instead of String.
  • Removes lifetime parameter from InstancePre.
  • No longer copies over the contents of the Module's func_types upon instantiation but efficiently clones via ref counting.

@paritytech-cicd-pr
Copy link

paritytech-cicd-pr commented Oct 21, 2022

BENCHMARKS

NATIVEWASMTIME
BENCHMARKMASTERPRDIFFMASTERPRDIFFWASMTIME OVERHEAD
execute/
bare_call_0
1.27ms 1.26ms ⚪ -0.78% 1.11ms 1.09ms 🔴 -1.47% 🟢 -13%
execute/
bare_call_0/typed
724.61µs 698.24µs ⚪ -2.76% 531.17µs 554.75µs 🔴 4.35% 🟢 -21%
execute/
bare_call_1
1.40ms 1.41ms 🔴 0.28% 1.41ms 1.35ms 🟢 -4.21% 🟢 -4%
execute/
bare_call_16
2.98ms 2.93ms 🔴 -1.93% 5.14ms 5.00ms 🟢 -2.74% 🟡 71%
execute/
bare_call_16/typed
1.28ms 1.43ms 🔴 10.31% 2.36ms 2.28ms 🟢 -3.54% 🟡 60%
execute/
bare_call_1/typed
804.56µs 809.31µs ⚪ 0.66% 876.48µs 874.58µs ⚪ -0.28% 🟢 8%
execute/
bare_call_4
1.75ms 1.73ms 🔴 -0.78% 2.17ms 2.13ms 🟢 -1.72% 🟢 23%
execute/
bare_call_4/typed
888.87µs 903.88µs 🔴 1.61% 987.02µs 979.43µs ⚪ -0.74% 🟢 8%
execute/
br_table
914.96µs 939.52µs 🔴 2.71% 1.10ms 1.12ms 🔴 1.24% 🟢 19%
execute/
count_until
903.18µs 903.14µs ⚪ 0.06% 2.33ms 2.27ms 🟢 -2.63% 🔴 151%
execute/
factorial_iterative
363.66µs 363.85µs ⚪ 0.07% 928.88µs 939.46µs 🔴 1.14% 🔴 158%
execute/
factorial_recursive
720.16µs 726.86µs ⚪ 0.91% 1.60ms 1.51ms 🟢 -5.84% 🔴 108%
execute/
fib_iterative
1.79ms 1.79ms ⚪ -0.11% 5.02ms 5.22ms 🔴 3.90% 🔴 192%
execute/
fib_recursive
8.17ms 6.92ms 🟢 -15.17% 15.22ms 14.10ms 🟢 -7.38% 🔴 104%
execute/
global_bump
1.36ms 1.36ms ⚪ -0.08% 3.63ms 3.55ms 🟢 -2.03% 🔴 161%
execute/
host_calls
32.73µs 36.24µs 🔴 10.50% 44.34µs 44.17µs ⚪ -0.34% 🟢 22%
execute/
memory_fill
1.55ms 1.55ms ⚪ -0.06% 4.22ms 4.14ms 🟢 -2.00% 🔴 166%
execute/
memory_sum
1.55ms 1.55ms ⚪ 0.06% 4.24ms 4.38ms 🔴 3.15% 🔴 183%
execute/
memory_vec_add
3.05ms 3.05ms ⚪ 0.03% 8.63ms 8.66ms ⚪ 0.34% 🔴 184%
execute/
recursive_is_even
1.30ms 1.31ms ⚪ 0.58% 2.59ms 2.58ms ⚪ -0.18% 🟡 97%
execute/
recursive_ok
172.16µs 172.23µs ⚪ 0.02% 360.95µs 360.88µs ⚪ 0.00% 🔴 110%
execute/
recursive_scan
215.32µs 214.58µs ⚪ -0.37% 466.80µs 462.25µs ⚪ -0.94% 🔴 115%
execute/
recursive_trap
17.20µs 17.13µs ⚪ -0.40% 36.15µs 36.06µs ⚪ -0.21% 🔴 111%
execute/
regex_redux
675.18µs 671.05µs ⚪ -0.55% 1.60ms 1.59ms ⚪ -0.74% 🔴 137%
execute/
rev_complement
591.66µs 586.28µs ⚪ -0.91% 1.53ms 1.54ms ⚪ 0.05% 🔴 162%
execute/
tiny_keccak
468.22µs 468.83µs ⚪ 0.23% 1.44ms 1.36ms 🟢 -5.20% 🔴 191%
execute/
trunc_f2i
1.08ms 1.02ms 🟢 -5.36% 2.64ms 2.57ms 🟢 -2.94% 🔴 152%
instantiate/
wasm_kernel
73.26µs 73.12µs ⚪ 0.32% 121.12µs 93.57µs 🟢 -22.90% 🟢 28%
translate/
wasm_kernel
4.15ms 4.13ms ⚪ -0.64% 7.91ms 7.73ms 🟢 -2.48% 🟡 87%

Link to pipeline

@Robbepop Robbepop merged commit a7c6f3c into master Oct 21, 2022
@Robbepop Robbepop deleted the rf-refactor-instantiate branch October 21, 2022 15:14
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