wasmi icon indicating copy to clipboard operation
wasmi copied to clipboard

Overhaul Pages and Bytes types

Open Robbepop opened this issue 3 years ago • 2 comments

Problems with previous types were found during fuzzy testing. These types make it simpler to fix linear memory allocation problems in wasmi for 32-bit and 64-bit architectures for edge cases.

Also we get rid of the memory_units dependency which did a lot more things that we actually needed in wasmi.

Robbepop avatar Sep 18 '22 08:09 Robbepop

Codecov Report

Merging #449 (889b301) into master (753b05d) will decrease coverage by 0.11%. The diff coverage is 69.73%.

@@            Coverage Diff             @@
##           master     #449      +/-   ##
==========================================
- Coverage   79.44%   79.33%   -0.12%     
==========================================
  Files          71       72       +1     
  Lines        6193     6241      +48     
==========================================
+ Hits         4920     4951      +31     
- Misses       1273     1290      +17     
Impacted Files Coverage Δ
wasmi_v1/src/memory/byte_buffer.rs 71.42% <63.63%> (-7.52%) :arrow_down:
core/src/units.rs 66.66% <66.66%> (ø)
wasmi_v1/src/engine/executor.rs 98.26% <71.42%> (-0.15%) :arrow_down:
wasmi_v1/src/memory/mod.rs 59.34% <77.77%> (+0.87%) :arrow_up:
wasmi_v1/src/module/utils.rs 86.36% <100.00%> (ø)
wasmi_v1/tests/spec/context.rs 77.98% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Sep 18 '22 08:09 codecov-commenter

BENCHMARKS

NATIVEWASMTIME
BENCHMARKMASTERPRDIFFMASTERPRDIFFWASMTIME OVERHEAD
execute/
bare_call_0
1.29ms 1.32ms :red_circle: 1.96% 1.12ms 1.10ms :red_circle: -1.89% :green_circle: -17%
execute/
bare_call_0/typed
703.72µs 754.52µs :red_circle: 7.16% 537.68µs 544.35µs :red_circle: 1.19% :green_circle: -28%
execute/
bare_call_1
1.40ms 1.44ms :red_circle: 3.33% 1.38ms 1.36ms :green_circle: -1.51% :green_circle: -6%
execute/
bare_call_16
3.03ms 3.07ms :white_circle: 2.39% 5.23ms 5.09ms :green_circle: -2.53% :yellow_circle: 66%
execute/
bare_call_16/typed
1.30ms 1.29ms :white_circle: -0.91% 2.53ms 2.37ms :green_circle: -6.35% :yellow_circle: 84%
execute/
bare_call_1/typed
805.39µs 874.88µs :red_circle: 8.71% 868.49µs 868.98µs :white_circle: -0.21% :green_circle: -1%
execute/
bare_call_4
1.77ms 1.75ms :red_circle: -0.78% 2.18ms 2.14ms :green_circle: -2.02% :green_circle: 22%
execute/
bare_call_4/typed
889.30µs 916.20µs :red_circle: 2.98% 1.01ms 985.45µs :green_circle: -2.22% :green_circle: 8%
execute/
br_table
907.59µs 945.51µs :red_circle: 4.13% 1.10ms 1.11ms :white_circle: 0.99% :green_circle: 18%
execute/
count_until
886.66µs 901.67µs :red_circle: 1.73% 2.21ms 2.33ms :red_circle: 5.64% :red_circle: 159%
execute/
factorial_iterative
362.63µs 363.73µs :white_circle: 0.35% 895.64µs 930.20µs :red_circle: 3.80% :red_circle: 156%
execute/
factorial_recursive
747.18µs 716.73µs :green_circle: -3.98% 1.50ms 1.54ms :red_circle: 2.58% :red_circle: 115%
execute/
fib_iterative
1.79ms 1.79ms :white_circle: -0.22% 4.92ms 5.47ms :red_circle: 11.38% :red_circle: 206%
execute/
fib_recursive
7.12ms 8.16ms :red_circle: 14.62% 13.59ms 14.17ms :red_circle: 4.25% :yellow_circle: 74%
execute/
global_bump
1.45ms 1.36ms :green_circle: -5.57% 3.50ms 3.83ms :red_circle: 9.47% :red_circle: 181%
execute/
host_calls
33.06µs 34.74µs :white_circle: 1.34% 45.26µs 45.49µs :white_circle: 0.58% :green_circle: 31%
execute/
memory_fill
1.53ms 1.56ms :red_circle: 1.33% 4.23ms 4.24ms :white_circle: 0.17% :red_circle: 172%
execute/
memory_sum
1.52ms 1.56ms :red_circle: 2.86% 4.17ms 4.25ms :red_circle: 1.93% :red_circle: 172%
execute/
memory_vec_add
4.76ms 3.06ms :green_circle: -36.16% 8.22ms 8.67ms :red_circle: 5.35% :red_circle: 183%
execute/
recursive_is_even
1.31ms 1.32ms :white_circle: 1.02% 2.55ms 2.59ms :red_circle: 1.87% :yellow_circle: 96%
execute/
recursive_ok
175.60µs 172.96µs :green_circle: -1.43% 351.76µs 362.25µs :red_circle: 2.93% :red_circle: 109%
execute/
recursive_scan
219.90µs 215.17µs :green_circle: -2.03% 454.72µs 468.96µs :red_circle: 3.31% :red_circle: 118%
execute/
recursive_trap
17.34µs 17.33µs :white_circle: -0.16% 34.82µs 36.40µs :red_circle: 4.73% :red_circle: 110%
execute/
regex_redux
652.39µs 675.53µs :red_circle: 3.47% 1.57ms 1.60ms :red_circle: 2.30% :red_circle: 136%
execute/
rev_complement
591.18µs 596.97µs :white_circle: 1.01% 1.52ms 1.54ms :white_circle: 1.14% :red_circle: 158%
execute/
tiny_keccak
481.94µs 471.69µs :white_circle: -1.83% 1.33ms 1.37ms :red_circle: 2.98% :red_circle: 191%
execute/
trunc_f2i
1.07ms 1.07ms :white_circle: 0.55% 2.41ms 2.65ms :red_circle: 10.16% :red_circle: 147%
instantiate/
wasm_kernel
68.36µs 72.02µs :red_circle: 5.69% 107.28µs 120.26µs :red_circle: 12.44% :yellow_circle: 67%
translate/
wasm_kernel
4.11ms 4.16ms :white_circle: 1.13% 7.83ms 7.89ms :white_circle: 0.67% :yellow_circle: 90%

Link to pipeline

paritytech-cicd-pr avatar Sep 18 '22 08:09 paritytech-cicd-pr

Could you also consider to extract memoryEntity type as a new crate?

yjhmelody avatar Oct 20 '22 09:10 yjhmelody

Could you also consider to extract memoryEntity type as a new crate?

i do not see a reason for this. also what does this has to do with this PR?

Robbepop avatar Oct 20 '22 09:10 Robbepop

Could you also consider to extract memoryEntity type as a new crate?

i do not see a reason for this. also what does this has to do with this PR?

I think it may be better to put Pages/Bytes into a wasmi_memory crate.

yjhmelody avatar Oct 20 '22 10:10 yjhmelody

Could you also consider to extract memoryEntity type as a new crate?

i do not see a reason for this. also what does this has to do with this PR?

I think it may be better to put Pages/Bytes into a wasmi_memory crate.

Yeah I got that but can you give me a compelling example as to why?

Robbepop avatar Oct 20 '22 11:10 Robbepop

Yeah I got that but can you give me a compelling example as to why?

No examples, simply because I need this crate too :(

yjhmelody avatar Oct 20 '22 11:10 yjhmelody

Yeah I got that but can you give me a compelling example as to why?

No examples, simply because I need this crate too :(

Cannot you use wasmi_core instead?

Robbepop avatar Oct 21 '22 11:10 Robbepop