Closed chenyan-dfinity closed 1 year ago
Note The flamegraph link only works after you merge. Unchanged benchmarks are omitted.
Measure the performance of some typical dapps:
heartbeat
disabled to make profiling easier. We have a separate benchmark to measure heartbeat performance.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.
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 |
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 |
Measure the cost of empty heartbeat and timer job.
setTimer
measures both the setTimer(0)
method and the execution of empty job.setTimer
and canister_global_timer
function. If it's not there, we may need to adjust the script.binary_size | heartbeat | |
---|---|---|
Motoko | 118_909 | 3_751 |
Rust | 29_905 | 916 |
binary_size | setTimer | cancelTimer | |
---|---|---|---|
Motoko | 125_168 | 15_208 | 1_679 |
Rust | 498_182 | 50_977 | 9_766 |
Basic DAO
DIP721 NFT
Heartbeat
Timer