dfinity / canister-profiling

Collection of canister performance benchmarks
Apache License 2.0
21 stars 8 forks source link

rust: opt 3 no lto #66

Closed chenyan-dfinity closed 1 year ago

github-actions[bot] commented 1 year ago

Note Diffing the performance result against the published result from main branch. Unchanged benchmarks are omitted.

Basic DAO

binary_size init transfer_token submit_proposal vote_proposal
Motoko 225_805 37_493 ($\textcolor{red}{0.06\%}$) 16_270 ($\textcolor{red}{0.26\%}$) 12_700 ($\textcolor{green}{-0.02\%}$) 14_155 ($\textcolor{green}{-0.01\%}$)
Rust 778_985 498_361 ($\textcolor{green}{-0.01\%}$) 93_215 114_281 124_684

DIP721 NFT

Note Same as main branch, skipping.

Heartbeat

binary_size heartbeat
Motoko 118_909 3_751
Rust 29_905 916 ($\textcolor{red}{67.46\%}$)

Timer

Note Same as main branch, skipping.

github-actions[bot] commented 1 year ago

Note The flamegraph link only works after you merge. Unchanged benchmarks are omitted.

Sample Dapps

Measure the performance of some typical dapps:

Note

  • The cost difference is mainly due to the Candid serialization cost.
  • Motoko statically compiles/specializes the serialization code for each method, whereas in Rust, we use serde to dynamically deserialize data based on data on the wire.
  • We could improve the performance on the Rust side by using parser combinators. But it is a challenge to maintain the ergonomics provided by serde.
  • For real-world applications, we tend to send small data for each endpoint, which makes the Candid overhead in Rust tolerable.

Basic DAO

binary_size init transfer_token submit_proposal vote_proposal
Motoko 225_805 37_493 16_270 12_700 14_155
Rust 778_985 498_361 93_215 114_281 124_684

DIP721 NFT

binary_size init mint_token transfer_token
Motoko 183_882 12_181 22_319 4_710
Rust 855_729 134_110 345_058 84_494

Heartbeat / Timer

Measure the cost of empty heartbeat and timer job.

Heartbeat

binary_size heartbeat
Motoko 118_909 3_751
Rust 29_905 916

Timer

binary_size setTimer cancelTimer
Motoko 125_168 15_208 1_679
Rust 498_182 50_977 9_766