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 | upgrade | |
---|---|---|---|---|---|---|
Motoko | 278_879 | 513_338 | 23_282 | 19_245 | 20_461 | 162_125 |
Rust | 902_362 | 516_184 | 92_673 | 118_753 | 113_669 | 1_499_571 |
binary_size | init | mint_token | transfer_token | upgrade | |
---|---|---|---|---|---|
Motoko | 225_006 | 482_239 | 31_104 | 8_880 | 92_429 |
Rust | 931_779 | 205_310 | 309_520 | 73_609 | 1_635_142 |
Environment
- dfx 0.24.0
- Motoko compiler 0.13.3 (source ff4il9yc-sfakbpl1-8z4dm2d6-ybdjncj7)
- rustc 1.81.0 (eeb90cda1 2024-09-04)
- ic-repl 0.7.6
- ic-wasm 0.9.0