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

Improve Wasmtime-like API for wasmi #615

Merged
merged 31 commits into from
Jan 17, 2023
Merged

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Jan 17, 2023

Mirror Wasmtime API more closely:

  • Renamed Caller::host_data method to Caller::data.
  • Renamed Caller::host_data_mut method to Caller::data_mut.
  • Add Extern::ty method and the ExternType type.
  • Rename ExportItem to ExportType:
    • Rename the ExportItem::kind method to ty and return ExternType instead of ExportItemKind.
    • Remove the no longer used ExportItemKind entirely.
  • The ExportsIter now yields items of the new type Export instead of pairs of (&str, Extern).
  • Rename ModuleImport to ImportType.
    • Rename ImportType::item_type to ty.
    • Rename ImportType::field to name.
    • Properly forward &str lifetimes in ImportType::{module, name}.
    • Replace ModuleImportType by ExternType.
  • Add new convenience methods to Instance:
    • Instance::get_func
    • Instance::get_typed_func
    • Instance::get_global
    • Instance::get_table
    • Instance::get_memory

More closely mirrors the Wasmtime API.
ExportType is the same name as used in the Wasmtime API.
They now align more closely to Wasmtime docs.
This more closely mirrors what the Wasmtime iterator yields.
Before that ExportsIter yielded pairs of (str, Extern) whereas now this pair is wrapped by the new Export type.
@paritytech-cicd-pr
Copy link

paritytech-cicd-pr commented Jan 17, 2023

BENCHMARKS

NATIVEWASMTIME
BENCHMARKMASTERPRDIFFMASTERPRDIFFWASMTIME OVERHEAD
execute/
bare_call_0
1.34ms 1.42ms 🔴 6.02% 1.17ms 1.14ms 🟢 -2.13% 🟢 -20%
execute/
bare_call_0/typed
985.89µs 1.01ms 🔴 2.74% 748.01µs 729.09µs 🟢 -2.27% 🟢 -28%
execute/
bare_call_1
1.44ms 1.45ms 🔴 1.77% 1.44ms 1.42ms 🔴 -2.03% 🟢 -2%
execute/
bare_call_16
2.35ms 2.53ms 🔴 7.77% 4.07ms 4.10ms 🟢 0.70% 🟡 62%
execute/
bare_call_16/typed
1.58ms 1.60ms ⚪ 1.27% 2.36ms 2.32ms 🟢 -1.88% 🟢 45%
execute/
bare_call_1/typed
1.10ms 1.10ms ⚪ 0.28% 1.06ms 1.09ms 🔴 2.17% 🟢 -1%
execute/
bare_call_4
1.59ms 1.65ms 🔴 3.84% 2.05ms 1.97ms 🟢 -3.74% 🟢 19%
execute/
bare_call_4/typed
1.10ms 1.12ms 🔴 1.51% 1.14ms 1.12ms 🟢 -1.92% 🟢 -1%
execute/
br_table
1.17ms 1.09ms 🟢 -5.43% 1.29ms 1.25ms 🟢 -3.39% 🟢 14%
execute/
count_until
682.69µs 710.12µs 🔴 4.12% 2.24ms 2.24ms ⚪ 0.36% 🔴 216%
execute/
factorial_iterative
326.57µs 326.70µs ⚪ 0.02% 907.25µs 908.56µs ⚪ 0.29% 🔴 178%
execute/
factorial_recursive
632.93µs 637.19µs ⚪ 0.60% 1.38ms 1.37ms ⚪ -1.04% 🔴 114%
execute/
fib_iterative
1.45ms 1.87ms 🔴 28.32% 4.68ms 4.68ms ⚪ -0.16% 🔴 151%
execute/
fib_recursive
5.75ms 5.75ms ⚪ 0.04% 12.24ms 12.23ms ⚪ -0.59% 🔴 113%
execute/
global_bump
990.44µs 1.02ms 🔴 2.52% 3.32ms 3.32ms ⚪ 0.05% 🔴 227%
execute/
global_const
742.72µs 718.61µs 🟢 -3.06% 2.58ms 2.58ms ⚪ 0.00% 🔴 259%
execute/
host_calls
29.44µs 29.18µs ⚪ -0.79% 43.36µs 41.42µs 🟢 -4.28% 🟢 42%
execute/
memory_fill
1.30ms 1.30ms ⚪ 0.05% 3.98ms 3.99ms ⚪ 0.64% 🔴 206%
execute/
memory_sum
1.27ms 1.30ms 🔴 2.45% 3.95ms 3.95ms ⚪ -0.16% 🔴 203%
execute/
memory_vec_add
2.57ms 2.55ms ⚪ -0.86% 8.25ms 8.23ms ⚪ -0.33% 🔴 222%
execute/
recursive_is_even
1.16ms 1.14ms ⚪ -1.11% 2.34ms 2.24ms 🟢 -4.39% 🟡 96%
execute/
recursive_ok
148.01µs 150.38µs 🔴 1.54% 325.06µs 312.90µs 🟢 -3.66% 🔴 108%
execute/
recursive_scan
180.40µs 180.96µs ⚪ 0.38% 418.16µs 404.91µs 🟢 -2.99% 🔴 124%
execute/
recursive_trap
14.37µs 14.42µs ⚪ 0.34% 31.81µs 31.70µs ⚪ -0.41% 🔴 120%
execute/
regex_redux
537.26µs 539.60µs ⚪ 0.49% 1.48ms 1.48ms ⚪ -0.34% 🔴 174%
execute/
rev_complement
506.77µs 488.53µs 🟢 -3.60% 1.41ms 1.42ms ⚪ 0.55% 🔴 190%
execute/
tiny_keccak
372.46µs 361.35µs 🟢 -2.86% 1.16ms 1.17ms ⚪ 0.92% 🔴 225%
execute/
trunc_f2i
907.82µs 908.50µs ⚪ 0.04% 2.50ms 2.51ms ⚪ 0.13% 🔴 176%
instantiate/
wasm_kernel
63.64µs 67.93µs ⚪ 2.72% 106.07µs 107.20µs ⚪ 0.00% 🟡 58%
translate/
erc1155
210.32µs 210.91µs ⚪ 0.39% 405.77µs 403.83µs ⚪ -0.30% 🟡 91%
translate/
erc20
103.41µs 103.16µs ⚪ 0.33% 199.22µs 203.02µs ⚪ 1.60% 🟡 97%
translate/
erc721
148.44µs 147.18µs ⚪ -1.11% 290.53µs 295.34µs ⚪ 14.96% 🔴 101%
translate/
spidermonkey
0.00ns 0.00ns ⚪ -0.25% 0.00ns 0.00ns ⚪ 1.73% 🟢 0%
translate/
wasm_kernel
3.82ms 3.77ms ⚪ -0.66% 7.82ms 7.99ms 🔴 2.47% 🔴 112%

Link to pipeline

@Robbepop Robbepop merged commit b9168b0 into master Jan 17, 2023
@Robbepop Robbepop deleted the rf-improve-wasmtime-api branch January 17, 2023 14:11
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