mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-04-21 23:47:57 +00:00
a4dde28607
* fix misprints in doc comments * added global gas tracker variable and local gas fn * all exported functions of the module to accept a new param and to set the gas_left global to its value at their very start * make module support both gas metering methods * tests fixed for the old metering method * better naming * MutableGlobal metering method implemented, tests for the old method pass * gas_metering::tests updated and pass * all tests udpdated and pass * emacs backup files to .gitignore * docs updated * clippy fix * iff = if and only if * more clippy * docs misprints fixes * refactored to have Backend trait and two implementations in separate sub-modules * docs updated * fixed old benches (updating them is coming next) * added bench for an instrumented wasm-coremark * updated benches: added them for both gas_metering instrumentations * benches contest first ver * added debug prints to the bench * refactored to better fit frontend-backend pattern * docs update * updated benches * design updated on feedback * re-structured sub-modules re-structured sub-modules & updated docs * docs improved * addressed latest feedback comments * re-writed the local gas function * coremark benches show ~20% performance improvement * fix ci: test + clippy * save before re-factoring prepare_in_wasm() * bare_call_16 shows 16% worse perf * + fibonacci recursive bench * refactored benchmarks * + factorial recursive bench * benches on wasmi fixtures show no perf improvement, coremark runs ~20% faster being instrumented with mutable_global gas metering * charge gas for local gas func isntructions execution * replaced benchmark which requires multi_value feature * save: optimized gas func a bit (benches work, fixture tests fail) * 1033% overhead on many_blocks.wasm when mut_global gas_metering together with stack_height * size overhead test for both gas metering methods + stack limiter * added more benches * improved print_size_overhead test * test for comparing size overheads of two gas_metering injectors * before optimization: benches + size overhead * optimization try-1: inline part of gas func instructions: +benches +size overheads * optimization try-2: inline hot path of gas fn: +benches +size overheads * opt try-3: count for gas fn cost on the caller side: +benches +size overhead * revert to initial version but with static gas fn cost on the caller side: +benches +sizes * tests fixed * use newest wasmi 0.20: +benches +docs updated * use if-else block instead of Return: +benches * fix tests * clippy fix * addressed review comments * Update changelog Co-authored-by: Alexander Theißen <alex.theissen@me.com>
5.6 KiB
5.6 KiB
Benchmarks
Table of Contents
Instrumented Modules sizes
| fixture | original size | gas metered/host fn | gas metered/mut global | size diff |
|---|---|---|---|---|
| recursive_ok.wat | 0 kb | 0 kb (137%) | 0 kb (177%) | +29% |
| count_until.wat | 0 kb | 0 kb (125%) | 0 kb (153%) | +21% |
| global_bump.wat | 0 kb | 0 kb (123%) | 0 kb (145%) | +18% |
| memory-vec-add.wat | 0 kb | 0 kb (116%) | 0 kb (134%) | +15% |
| factorial.wat | 0 kb | 0 kb (125%) | 0 kb (145%) | +15% |
| fibonacci.wat | 0 kb | 0 kb (121%) | 0 kb (134%) | +10% |
| contract_terminate.wasm | 1 kb | 1 kb (110%) | 1 kb (112%) | +2% |
| coremark_minimal.wasm | 7 kb | 8 kb (114%) | 8 kb (115%) | +0% |
| trait_erc20.wasm | 10 kb | 11 kb (108%) | 11 kb (108%) | +0% |
| rand_extension.wasm | 4 kb | 5 kb (109%) | 5 kb (109%) | +0% |
| multisig.wasm | 27 kb | 30 kb (110%) | 30 kb (110%) | +0% |
| wasm_kernel.wasm | 779 kb | 787 kb (100%) | 795 kb (101%) | +0% |
| many_blocks.wasm | 1023 kb | 2389 kb (233%) | 2389 kb (233%) | +0% |
| contract_transfer.wasm | 7 kb | 8 kb (113%) | 8 kb (113%) | +0% |
| erc1155.wasm | 26 kb | 29 kb (111%) | 29 kb (111%) | +0% |
| erc20.wasm | 9 kb | 10 kb (108%) | 10 kb (109%) | +0% |
| dns.wasm | 10 kb | 11 kb (108%) | 11 kb (108%) | +0% |
| proxy.wasm | 3 kb | 4 kb (108%) | 4 kb (109%) | +0% |
| erc721.wasm | 13 kb | 14 kb (108%) | 14 kb (108%) | +0% |
Benchmark Results
coremark, instrumented
with host_function::Injector |
with mutable_global::Injector |
|
|---|---|---|
20.81 s (✅ 1.00x) |
20.20 s (✅ 1.03x faster) |
recursive_ok, instrumented
with host_function::Injector |
with mutable_global::Injector |
|
|---|---|---|
367.11 us (✅ 1.00x) |
585.39 us (❌ 1.59x slower) |
fibonacci_recursive, instrumented
with host_function::Injector |
with mutable_global::Injector |
|
|---|---|---|
9.15 us (✅ 1.00x) |
13.56 us (❌ 1.48x slower) |
factorial_recursive, instrumented
with host_function::Injector |
with mutable_global::Injector |
|
|---|---|---|
1.50 us (✅ 1.00x) |
1.98 us (❌ 1.32x slower) |
count_until, instrumented
with host_function::Injector |
with mutable_global::Injector |
|
|---|---|---|
5.03 ms (✅ 1.00x) |
8.13 ms (❌ 1.62x slower) |
memory_vec_add, instrumented
with host_function::Injector |
with mutable_global::Injector |
|
|---|---|---|
6.21 ms (✅ 1.00x) |
8.45 ms (❌ 1.36x slower) |
wasm_kernel::tiny_keccak, instrumented
with host_function::Injector |
with mutable_global::Injector |
|
|---|---|---|
925.22 us (✅ 1.00x) |
1.08 ms (❌ 1.17x slower) |
global_bump, instrumented
with host_function::Injector |
with mutable_global::Injector |
|
|---|---|---|
3.79 ms (✅ 1.00x) |
7.03 ms (❌ 1.86x slower) |
Made with criterion-table