Skip to content

implement borsh serialize and deserialize artifact - #1

Merged
ailisp merged 24 commits into
0.17.2from
borsh-serialize-artifact
Jul 2, 2021
Merged

implement borsh serialize and deserialize artifact#1
ailisp merged 24 commits into
0.17.2from
borsh-serialize-artifact

Conversation

@ailisp

@ailisp ailisp commented Dec 18, 2020

Copy link
Copy Markdown
Contributor

Fixed cargo test pass again after change. There's a benchmark fn create_instance_from_cache_benchmark(c: &mut Criterion) { covers the change of this PR, and it gives a 20%-30% performance increase in this bench (a nightly rust is required):

cargo bench --features backend-singlepass -p wasmer-runtime
0.17.2:
instantiate from cache  time:   [297.62 us 311.67 us 326.03 us]     
                        change: [+2.8418% +7.3613% +12.377%] (p = 0.00 < 0.05)
                        Performance has regressed.

borsh-serialize-artifact:
instantiate from cache  time:   [240.00 us 242.27 us 245.50 us]
                        change: [-23.253% -20.755% -18.172%] (p = 0.00 < 0.05)
                        Performance has improved.
another time, even faster:
instantiate from cache  time:   [227.04 us 228.65 us 230.53 us]
                        change: [-2.4430% +0.0532% +2.4097%] (p = 0.97 > 0.05)
                        No change in performance detected.


I also run param estimator with serde wasmer nearcore vs borsh wasmer nearcore, it's still running in progress

@ailisp
ailisp requested review from olonho and willemneal December 18, 2020 01:58

@olonho olonho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, maybe rename map -> index_map.

@ailisp

ailisp commented Dec 22, 2020

Copy link
Copy Markdown
Contributor Author

There is almost no change in cost, if consider volatility in each run. second == borsh_wasmer, first == master

runtime-params-estimator (fix-ecrecover) python3 emu-cost/compare_costs.py ~/master_config.json ~/borsh_wasmer_config.json 
storage_amount_per_byte: first=90900000000000000000 second=90900000000000000000 second/first=1.00
transaction_costs.action_receipt_creation_config.send_sir: first=143750937500 second=143534750000 second/first=1.00
transaction_costs.action_receipt_creation_config.send_not_sir: first=143750937500 second=143534750000 second/first=1.00
transaction_costs.action_receipt_creation_config.execution: first=143750937500 second=143534750000 second/first=1.00
transaction_costs.data_receipt_creation_config.base_cost.send_sir: first=34488148062 second=34684176812 second/first=1.01
transaction_costs.data_receipt_creation_config.base_cost.send_not_sir: first=34488148062 second=34684176812 second/first=1.01
transaction_costs.data_receipt_creation_config.base_cost.execution: first=34488148062 second=34684176812 second/first=1.01
transaction_costs.data_receipt_creation_config.cost_per_byte.send_sir: first=13477633 second=13479678 second/first=1.00
transaction_costs.data_receipt_creation_config.cost_per_byte.send_not_sir: first=13477633 second=13479678 second/first=1.00
transaction_costs.data_receipt_creation_config.cost_per_byte.execution: first=13477633 second=13479678 second/first=1.00
transaction_costs.action_creation_config.create_account_cost.send_sir: first=15266312500 second=18186625000 second/first=1.19
transaction_costs.action_creation_config.create_account_cost.send_not_sir: first=15266312500 second=18186625000 second/first=1.19
transaction_costs.action_creation_config.create_account_cost.execution: first=15266312500 second=18186625000 second/first=1.19
transaction_costs.action_creation_config.deploy_contract_cost.send_sir: first=31504500000 second=29339812500 second/first=0.93
transaction_costs.action_creation_config.deploy_contract_cost.send_not_sir: first=31504500000 second=29339812500 second/first=0.93
transaction_costs.action_creation_config.deploy_contract_cost.execution: first=31504500000 second=29339812500 second/first=0.93
transaction_costs.action_creation_config.deploy_contract_cost_per_byte.send_sir: first=6435854 second=6442900 second/first=1.00
transaction_costs.action_creation_config.deploy_contract_cost_per_byte.send_not_sir: first=6435854 second=6442900 second/first=1.00
transaction_costs.action_creation_config.deploy_contract_cost_per_byte.execution: first=6435854 second=6442900 second/first=1.00
transaction_costs.action_creation_config.function_call_cost.send_sir: first=226469187500 second=220247125000 second/first=0.97
transaction_costs.action_creation_config.function_call_cost.send_not_sir: first=226469187500 second=220247125000 second/first=0.97
transaction_costs.action_creation_config.function_call_cost.execution: first=226469187500 second=220247125000 second/first=0.97
transaction_costs.action_creation_config.function_call_cost_per_byte.send_sir: first=28490 second=28365 second/first=1.00
transaction_costs.action_creation_config.function_call_cost_per_byte.send_not_sir: first=28490 second=28365 second/first=1.00
transaction_costs.action_creation_config.function_call_cost_per_byte.execution: first=28490 second=28365 second/first=1.00
transaction_costs.action_creation_config.transfer_cost.send_sir: first=18104562500 second=16758687500 second/first=0.93
transaction_costs.action_creation_config.transfer_cost.send_not_sir: first=18104562500 second=16758687500 second/first=0.93
transaction_costs.action_creation_config.transfer_cost.execution: first=18104562500 second=16758687500 second/first=0.93
transaction_costs.action_creation_config.stake_cost.send_sir: first=54719125000 second=57512312500 second/first=1.05
transaction_costs.action_creation_config.stake_cost.send_not_sir: first=54719125000 second=57512312500 second/first=1.05
transaction_costs.action_creation_config.stake_cost.execution: first=54719125000 second=57512312500 second/first=1.05
transaction_costs.action_creation_config.add_key_cost.full_access_cost.send_sir: first=20836875000 second=21625812500 second/first=1.04
transaction_costs.action_creation_config.add_key_cost.full_access_cost.send_not_sir: first=20836875000 second=21625812500 second/first=1.04
transaction_costs.action_creation_config.add_key_cost.full_access_cost.execution: first=20836875000 second=21625812500 second/first=1.04
transaction_costs.action_creation_config.add_key_cost.function_call_cost.send_sir: first=20138375000 second=21467125000 second/first=1.07
transaction_costs.action_creation_config.add_key_cost.function_call_cost.send_not_sir: first=20138375000 second=21467125000 second/first=1.07
transaction_costs.action_creation_config.add_key_cost.function_call_cost.execution: first=20138375000 second=21467125000 second/first=1.07
transaction_costs.action_creation_config.add_key_cost.function_call_cost_per_byte.send_sir: first=8721300 second=8736362 second/first=1.00
transaction_costs.action_creation_config.add_key_cost.function_call_cost_per_byte.send_not_sir: first=8721300 second=8736362 second/first=1.00
transaction_costs.action_creation_config.add_key_cost.function_call_cost_per_byte.execution: first=8721300 second=8736362 second/first=1.00
transaction_costs.action_creation_config.delete_key_cost.send_sir: first=7971062500 second=10364062500 second/first=1.30
transaction_costs.action_creation_config.delete_key_cost.send_not_sir: first=7971062500 second=10364062500 second/first=1.30
transaction_costs.action_creation_config.delete_key_cost.execution: first=7971062500 second=10364062500 second/first=1.30
transaction_costs.action_creation_config.delete_account_cost.send_sir: first=93739062500 second=94554437500 second/first=1.01
transaction_costs.action_creation_config.delete_account_cost.send_not_sir: first=93739062500 second=94554437500 second/first=1.01
transaction_costs.action_creation_config.delete_account_cost.execution: first=93739062500 second=94554437500 second/first=1.01
transaction_costs.storage_usage_config.num_bytes_account: first=100 second=100 second/first=1.00
transaction_costs.storage_usage_config.num_extra_bytes_record: first=40 second=40 second/first=1.00
wasm_config.ext_costs.base: first=85068879 second=85064848 second/first=1.00
wasm_config.ext_costs.contract_compile_base: first=25160200000 second=25135150000 second/first=1.00
wasm_config.ext_costs.contract_compile_bytes: first=393100644 second=393017737 second/first=1.00
wasm_config.ext_costs.read_memory_base: first=241941600 second=242257100 second/first=1.00
wasm_config.ext_costs.read_memory_byte: first=1267036 second=1267037 second/first=1.00
wasm_config.ext_costs.write_memory_base: first=304485087 second=304815862 second/first=1.00
wasm_config.ext_costs.write_memory_byte: first=61620 second=61621 second/first=1.00
wasm_config.ext_costs.read_register_base: first=210034425 second=210173187 second/first=1.00
wasm_config.ext_costs.read_register_byte: first=32244 second=32245 second/first=1.00
wasm_config.ext_costs.write_register_base: first=335187812 second=335882775 second/first=1.00
wasm_config.ext_costs.write_register_byte: first=1267125 second=1267126 second/first=1.00
wasm_config.ext_costs.utf8_decoding_base: first=423280925 second=424171075 second/first=1.00
wasm_config.ext_costs.utf8_decoding_byte: first=101539190 second=101536276 second/first=1.00
wasm_config.ext_costs.utf16_decoding_base: first=563519212 second=563675775 second/first=1.00
wasm_config.ext_costs.utf16_decoding_byte: first=56237865 second=56233349 second/first=1.00
wasm_config.ext_costs.sha256_base: first=876801225 second=877220362 second/first=1.00
wasm_config.ext_costs.sha256_byte: first=7684789 second=7684759 second/first=1.00
wasm_config.ext_costs.keccak256_base: first=1317777837 second=1318515800 second/first=1.00
wasm_config.ext_costs.keccak256_byte: first=7065334 second=7065321 second/first=1.00
wasm_config.ext_costs.keccak512_base: first=1313077775 second=1313413462 second/first=1.00
wasm_config.ext_costs.keccak512_byte: first=12107503 second=12121209 second/first=1.00
wasm_config.ext_costs.log_base: first=563519212 second=563675775 second/first=1.00
wasm_config.ext_costs.log_byte: first=4193314 second=4192762 second/first=1.00
wasm_config.ext_costs.storage_write_base: first=10063841250 second=10906532625 second/first=1.08
wasm_config.ext_costs.storage_write_key_byte: first=21406224 second=21277370 second/first=0.99
wasm_config.ext_costs.storage_write_value_byte: first=8855404 second=8844624 second/first=1.00
wasm_config.ext_costs.storage_write_evicted_byte: first=5551638 second=5545563 second/first=1.00
wasm_config.ext_costs.storage_read_base: first=22859555375 second=22509759125 second/first=0.98
wasm_config.ext_costs.storage_read_key_byte: first=10638620 second=10516511 second/first=0.99
wasm_config.ext_costs.storage_read_value_byte: first=2261917 second=2306136 second/first=1.02
wasm_config.ext_costs.storage_remove_base: first=31036322875 second=31278250375 second/first=1.01
wasm_config.ext_costs.storage_remove_key_byte: first=23470355 second=23367596 second/first=1.00
wasm_config.ext_costs.storage_remove_ret_value_byte: first=3376102 second=3318981 second/first=0.98
wasm_config.ext_costs.storage_has_key_base: first=20161377250 second=20439124875 second/first=1.01
wasm_config.ext_costs.storage_has_key_byte: first=10468349 second=10389683 second/first=0.99
wasm_config.ext_costs.storage_iter_create_prefix_base: first=0 second=0 second/first=n/a
wasm_config.ext_costs.storage_iter_create_prefix_byte: first=0 second=0 second/first=n/a
wasm_config.ext_costs.storage_iter_create_range_base: first=0 second=0 second/first=n/a
wasm_config.ext_costs.storage_iter_create_from_byte: first=0 second=0 second/first=n/a
wasm_config.ext_costs.storage_iter_create_to_byte: first=0 second=0 second/first=n/a
wasm_config.ext_costs.storage_iter_next_base: first=0 second=0 second/first=n/a
wasm_config.ext_costs.storage_iter_next_key_byte: first=0 second=0 second/first=n/a
wasm_config.ext_costs.storage_iter_next_value_byte: first=0 second=0 second/first=n/a
wasm_config.ext_costs.touching_trie_node: first=6531301535 second=6431359750 second/first=0.98
wasm_config.ext_costs.promise_and_base: first=429556625 second=429539428 second/first=1.00
wasm_config.ext_costs.promise_and_per_promise: first=1827032 second=1828798 second/first=1.00
wasm_config.ext_costs.promise_return: first=123070086 second=123093292 second/first=1.00
wasm_config.ext_costs.validator_stake_base: first=303944908800 second=303944908800 second/first=1.00
wasm_config.ext_costs.validator_total_stake_base: first=303944908800 second=303944908800 second/first=1.00
wasm_config.grow_mem_cost: first=1 second=1 second/first=1.00
wasm_config.regular_op_cost: first=1139940 second=1145331 second/first=1.00
wasm_config.limit_config.max_gas_burnt: first=200000000000000 second=200000000000000 second/first=1.00
wasm_config.limit_config.max_gas_burnt_view: first=200000000000000 second=200000000000000 second/first=1.00
wasm_config.limit_config.max_stack_height: first=16384 second=16384 second/first=1.00
wasm_config.limit_config.initial_memory_pages: first=1024 second=1024 second/first=1.00
wasm_config.limit_config.max_memory_pages: first=2048 second=2048 second/first=1.00
wasm_config.limit_config.registers_memory_limit: first=1073741824 second=1073741824 second/first=1.00
wasm_config.limit_config.max_register_size: first=104857600 second=104857600 second/first=1.00
wasm_config.limit_config.max_number_registers: first=100 second=100 second/first=1.00
wasm_config.limit_config.max_number_logs: first=100 second=100 second/first=1.00
wasm_config.limit_config.max_total_log_length: first=16384 second=16384 second/first=1.00
wasm_config.limit_config.max_total_prepaid_gas: first=300000000000000 second=300000000000000 second/first=1.00
wasm_config.limit_config.max_actions_per_receipt: first=100 second=100 second/first=1.00
wasm_config.limit_config.max_number_bytes_method_names: first=2000 second=2000 second/first=1.00
wasm_config.limit_config.max_length_method_name: first=256 second=256 second/first=1.00
wasm_config.limit_config.max_arguments_length: first=4194304 second=4194304 second/first=1.00
wasm_config.limit_config.max_length_returned_data: first=4194304 second=4194304 second/first=1.00
wasm_config.limit_config.max_contract_size: first=4194304 second=4194304 second/first=1.00
wasm_config.limit_config.max_length_storage_key: first=4194304 second=4194304 second/first=1.00
wasm_config.limit_config.max_length_storage_value: first=4194304 second=4194304 second/first=1.00
wasm_config.limit_config.max_promises_per_function_call_action: first=1024 second=1024 second/first=1.00
wasm_config.limit_config.max_number_input_data_dependencies: first=128 second=128 second/first=1.00
account_creation_config.min_allowed_top_level_account_length: first=0 second=0 second/first=n/a

ailisp pushed a commit that referenced this pull request Jan 15, 2021
…lized-results-memory

test(c-api) Enable the memory test example.