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 lazy fuel consumption #877

Merged
merged 22 commits into from Jan 11, 2024
Merged

Conversation

Robbepop
Copy link
Collaborator

@Robbepop Robbepop commented Jan 7, 2024

Closes #874.

This allows to efficiently use this type for fuel consumption in the executor.
Replaced by a simpler Option<&mut Fuel> type.
This new functionality is unused by the engine executor as for now.
@Robbepop Robbepop marked this pull request as draft January 7, 2024 21:59
@paritytech-cicd-pr
Copy link

paritytech-cicd-pr commented Jan 7, 2024

BENCHMARKS

NATIVEWASMTIME
BENCHMARKMASTERPRDIFFMASTERPRDIFFWASMTIME OVERHEAD
execute/
br_table
1.51ms 1.55ms 🔴 3.02% 1.36ms 1.37ms ⚪ 0.87% 🟢 -12%
execute/
call/host/1
50.03µs 51.62µs 🔴 3.16% 63.92µs 61.58µs 🟢 -3.67% 🟢 19%
execute/
call/rec
171.83µs 173.98µs ⚪ 1.25% 334.51µs 332.90µs ⚪ -0.48% 🟡 91%
execute/
count_until
5.54ms 5.33ms 🟢 -3.74% 7.45ms 7.33ms 🟢 -1.54% 🟢 38%
execute/
divrem
6.33ms 6.32ms ⚪ -0.11% 6.96ms 6.93ms ⚪ -0.40% 🟢 10%
execute/
factorial/iter
265.03µs 244.20µs 🟢 -7.86% 313.26µs 305.98µs 🟢 -2.32% 🟢 25%
execute/
factorial/rec
683.40µs 700.61µs 🔴 2.52% 1.25ms 1.24ms ⚪ -1.01% 🟡 77%
execute/
fibonacci/iter
1.33ms 1.32ms ⚪ -0.81% 1.21ms 1.27ms 🔴 5.51% 🟢 -3%
execute/
fibonacci/rec
6.12ms 5.92ms 🟢 -3.25% 12.43ms 12.49ms ⚪ 0.53% 🔴 111%
execute/
fibonacci/tail
1.26ms 1.34ms 🔴 6.40% 4.36ms 4.37ms ⚪ 0.10% 🔴 226%
execute/
fuse
7.25ms 7.05ms 🟢 -2.78% 11.12ms 11.18ms ⚪ 0.49% 🟡 59%
execute/
global/bump
1.32ms 1.35ms ⚪ 2.45% 1.57ms 1.58ms ⚪ 0.98% 🟢 17%
execute/
global/get_const
481.64µs 478.82µs ⚪ -0.59% 744.65µs 746.83µs ⚪ 0.29% 🟡 56%
execute/
is_even/rec
1.14ms 1.13ms ⚪ -0.79% 2.10ms 2.09ms ⚪ -0.65% 🟡 84%
execute/
memory/fill_bytes
962.67µs 1.10ms 🔴 13.98% 1.25ms 1.23ms 🟢 -1.73% 🟢 12%
execute/
memory/sum_bytes
1.00ms 1.06ms 🔴 5.48% 1.24ms 1.24ms ⚪ -0.34% 🟢 17%
execute/
memory/vec_add
2.94ms 3.14ms ⚪ 6.63% 3.47ms 3.58ms 🔴 3.10% 🟢 14%
execute/
recursive_scan
199.97µs 191.34µs 🟢 -4.32% 356.36µs 354.86µs ⚪ -0.42% 🟡 85%
execute/
recursive_trap
16.20µs 16.23µs ⚪ 0.22% 32.28µs 33.08µs 🔴 2.48% 🔴 104%
execute/
regex_redux
586.91µs 590.35µs ⚪ 0.59% 1.15ms 1.16ms ⚪ 0.30% 🟡 96%
execute/
rev_complement
443.33µs 451.97µs 🔴 1.95% 680.96µs 696.54µs 🔴 2.29% 🟡 54%
execute/
tiny_keccak
351.58µs 353.25µs ⚪ 0.48% 382.48µs 388.53µs 🔴 1.58% 🟢 10%
execute/
trunc_f2i
594.59µs 649.96µs 🔴 9.31% 942.05µs 938.52µs ⚪ -0.37% 🟢 44%
instantiate/
wasm_kernel
53.94µs 55.75µs ⚪ 3.36% 54.68µs 55.20µs ⚪ 0.95% 🟢 -1%
overhead/
call/typed/0
1.28ms 1.24ms 🟢 -2.69% 910.46µs 1.05ms 🔴 15.70% 🟢 -15%
overhead/
call/typed/16
1.63ms 1.65ms ⚪ 0.89% 2.92ms 2.79ms 🟢 -4.37% 🟡 70%
overhead/
call/untyped/0
1.57ms 1.59ms ⚪ 1.26% 1.19ms 1.27ms 🔴 7.18% 🟢 -20%
overhead/
call/untyped/16
2.38ms 2.49ms 🔴 4.64% 4.74ms 4.56ms 🟢 -3.76% 🟡 83%
translate/
bz2/checked/eager/default
1.33ms 1.33ms ⚪ 0.43% 2.46ms 2.41ms 🟢 -2.28% 🟡 80%
translate/
bz2/checked/eager/fuel
1.43ms 1.44ms ⚪ 1.01% 2.67ms 2.63ms 🟢 -1.77% 🟡 82%
translate/
bz2/checked/lazy-translation/default
545.87µs 540.47µs ⚪ -0.99% 967.57µs 975.95µs ⚪ 0.87% 🟡 81%
translate/
bz2/checked/lazy/default
36.99µs 36.97µs ⚪ -0.04% 45.96µs 45.25µs 🟢 -1.55% 🟢 22%
translate/
bz2/unchecked/eager/default
1.08ms 1.09ms ⚪ 0.93% 1.85ms 1.91ms 🔴 3.12% 🟡 75%
translate/
erc1155/checked/eager/default
279.19µs 279.73µs ⚪ 0.20% 478.59µs 473.17µs ⚪ -1.13% 🟡 69%
translate/
erc1155/checked/eager/fuel
299.05µs 300.43µs ⚪ 0.46% 511.10µs 507.37µs ⚪ -0.73% 🟡 69%
translate/
erc1155/checked/lazy-translation/default
128.83µs 127.91µs ⚪ -0.71% 213.21µs 211.82µs ⚪ -0.65% 🟡 66%
translate/
erc1155/checked/lazy/default
25.78µs 25.87µs ⚪ 0.33% 32.94µs 32.07µs 🟢 -2.64% 🟢 24%
translate/
erc1155/unchecked/eager/default
231.10µs 231.96µs ⚪ 0.37% 369.34µs 376.52µs 🔴 1.94% 🟡 62%
translate/
erc20/checked/eager/default
135.74µs 135.88µs ⚪ 0.10% 228.12µs 226.41µs ⚪ -0.75% 🟡 67%
translate/
erc20/checked/eager/fuel
143.74µs 144.14µs ⚪ 0.28% 241.16µs 239.66µs ⚪ -0.62% 🟡 66%
translate/
erc20/checked/lazy-translation/default
66.08µs 65.62µs ⚪ -0.70% 106.97µs 107.06µs ⚪ 0.09% 🟡 63%
translate/
erc20/checked/lazy/default
18.89µs 18.90µs ⚪ 0.04% 24.76µs 24.42µs 🟢 -1.39% 🟢 29%
translate/
erc20/unchecked/eager/default
111.37µs 112.70µs ⚪ 1.20% 176.34µs 179.06µs 🔴 1.54% 🟡 59%
translate/
erc721/checked/eager/default
193.15µs 194.03µs ⚪ 0.46% 331.14µs 327.71µs ⚪ -1.04% 🟡 69%
translate/
erc721/checked/eager/fuel
202.43µs 204.17µs ⚪ 0.86% 349.22µs 346.19µs ⚪ -0.87% 🟡 70%
translate/
erc721/checked/lazy-translation/default
92.01µs 91.77µs ⚪ -0.27% 155.60µs 151.55µs 🟢 -2.60% 🟡 65%
translate/
erc721/checked/lazy/default
23.35µs 23.01µs ⚪ -1.44% 29.03µs 28.57µs 🟢 -1.58% 🟢 24%
translate/
erc721/unchecked/eager/default
156.18µs 157.71µs ⚪ 0.98% 250.87µs 256.18µs 🔴 2.11% 🟡 62%
translate/
pulldown_cmark/checked/eager/default
3.62ms 3.63ms ⚪ 0.21% 6.25ms 6.17ms 🟢 -1.32% 🟡 70%
translate/
pulldown_cmark/checked/eager/fuel
3.89ms 3.90ms ⚪ 0.22% 6.70ms 6.67ms ⚪ -0.51% 🟡 71%
translate/
pulldown_cmark/checked/lazy-translation/default
1.54ms 1.53ms ⚪ -0.92% 2.57ms 2.58ms ⚪ 0.52% 🟡 69%
translate/
pulldown_cmark/checked/lazy/default
256.53µs 250.52µs 🟢 -2.34% 243.68µs 250.61µs 🔴 2.84% 🟢 0%
translate/
pulldown_cmark/unchecked/eager/default
3.03ms 3.04ms ⚪ 0.20% 4.83ms 4.95ms 🔴 2.42% 🟡 63%
translate/
spidermonkey/checked/eager/default
76.41ms 76.97ms ⚪ 0.73% 135.14ms 133.93ms ⚪ -0.90% 🟡 74%
translate/
spidermonkey/checked/eager/fuel
82.71ms 83.24ms ⚪ 0.64% 145.51ms 144.36ms ⚪ -0.78% 🟡 73%
translate/
spidermonkey/checked/lazy-translation/default
32.65ms 32.28ms ⚪ -1.13% 55.47ms 56.16ms 🔴 1.24% 🟡 74%
translate/
spidermonkey/checked/lazy/default
3.28ms 3.24ms ⚪ -1.01% 3.89ms 3.81ms 🟢 -2.10% 🟢 18%
translate/
spidermonkey/unchecked/eager/default
63.41ms 63.94ms ⚪ 0.83% 103.60ms 106.16ms 🔴 2.48% 🟡 66%
translate/
wasm_kernel/checked/eager/default
5.09ms 5.08ms ⚪ -0.35% 8.77ms 8.65ms 🟢 -1.35% 🟡 70%
translate/
wasm_kernel/checked/eager/fuel
5.25ms 5.23ms ⚪ -0.37% 9.20ms 9.12ms ⚪ -0.85% 🟡 74%
translate/
wasm_kernel/checked/lazy-translation/default
2.44ms 2.40ms 🟢 -1.71% 3.99ms 4.01ms ⚪ 0.52% 🟡 67%
translate/
wasm_kernel/checked/lazy/default
427.07µs 429.08µs ⚪ 0.47% 492.35µs 515.88µs ⚪ 4.78% 🟢 20%
translate/
wasm_kernel/unchecked/eager/default
4.12ms 4.14ms ⚪ 0.70% 6.66ms 6.84ms 🔴 2.82% 🟡 65%

Link to pipeline

@codecov-commenter
Copy link

codecov-commenter commented Jan 7, 2024

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (d80c19f) 80.71% compared to head (e143932) 81.08%.

Files Patch % Lines
crates/wasmi/src/engine/code_map.rs 0.00% 7 Missing ⚠️
crates/wasmi/src/table/mod.rs 61.11% 7 Missing ⚠️
crates/wasmi/src/memory/mod.rs 84.21% 3 Missing ⚠️
crates/wasmi/src/store.rs 92.10% 3 Missing ⚠️
crates/wasmi/src/engine/executor/instrs.rs 50.00% 2 Missing ⚠️
crates/wasmi/src/engine/executor/instrs/memory.rs 97.87% 1 Missing ⚠️
crates/wasmi/src/engine/executor/instrs/table.rs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #877      +/-   ##
==========================================
+ Coverage   80.71%   81.08%   +0.36%     
==========================================
  Files         256      256              
  Lines       22919    22907      -12     
==========================================
+ Hits        18500    18573      +73     
+ Misses       4419     4334      -85     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Robbepop
Copy link
Collaborator Author

Robbepop commented Jan 9, 2024

@graydon This improves fuel consumption for instructions that consume an amount of fuel that cannot be determined at compilation time. For example, memory.{grow,copy,fill,init} and table.{grow,copy,fill,init}. Among others this changed implementations of {memory,table}.grow which you touched last. I made sure that the resource_limiter behavior mostly remained the same (with new built-in fuel charging).

Methods you might want to check:

@Robbepop Robbepop marked this pull request as ready for review January 9, 2024 10:10
@Robbepop Robbepop merged commit 17b5321 into master Jan 11, 2024
21 checks passed
@Robbepop Robbepop deleted the rf-improve-lazy-fuel-consumption-mode branch January 11, 2024 16:25
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.

Improve FuelConsumptionMode::Lazy
4 participants