Closed kentosugama closed 1 year ago
Note Diffing the performance result against the published result from main branch
binary_size | heartbeat | |
---|---|---|
Motoko | 121_920 ($\textcolor{green}{-17.13\%}$) | 11_354 ($\textcolor{green}{-4.89\%}$) |
Rust | 27_253 ($\textcolor{green}{-23.55\%}$) | 1_080 ($\textcolor{red}{83.99\%}$) |
binary_size | setTimer | cancelTimer | |
---|---|---|---|
Motoko | 135_637 ($\textcolor{green}{-16.76\%}$) | 32_210 ($\textcolor{green}{-7.01\%}$) | 1_748 ($\textcolor{green}{-9.10\%}$) |
Rust | 424_735 ($\textcolor{green}{-19.20\%}$) | 53_825 ($\textcolor{green}{-3.55\%}$) | 10_153 ($\textcolor{green}{-3.68\%}$) |
binary_size | generate 50k | max mem | batch_get 50 | batch_put 50 | batch_remove 50 | |
---|---|---|---|---|---|---|
hashmap | 162_667 ($\textcolor{green}{-16.84\%}$) | 2_112_036_256 ($\textcolor{green}{-11.52\%}$) | 9_102_052 | 1_124_437 ($\textcolor{green}{-13.06\%}$) | 613_910_550 ($\textcolor{green}{-10.92\%}$) | 1_065_165 ($\textcolor{green}{-13.06\%}$) |
triemap | 166_893 ($\textcolor{green}{-17.13\%}$) | 2_036_258_951 ($\textcolor{green}{-11.06\%}$) | 9_716_008 | 781_608 ($\textcolor{green}{-12.48\%}$) | 1_868_829 ($\textcolor{green}{-11.65\%}$) | 1_042_928 ($\textcolor{green}{-12.47\%}$) |
rbtree | 165_811 ($\textcolor{green}{-16.92\%}$) | 1_895_737_241 ($\textcolor{green}{-10.48\%}$) | 10_102_184 | 709_153 ($\textcolor{green}{-13.90\%}$) | 1_705_707 ($\textcolor{green}{-11.04\%}$) | 946_478 ($\textcolor{green}{-12.52\%}$) |
splay | 163_998 ($\textcolor{green}{-17.02\%}$) | 2_105_962_355 ($\textcolor{green}{-10.76\%}$) | 9_302_108 | 1_155_004 ($\textcolor{green}{-11.53\%}$) | 1_976_076 ($\textcolor{green}{-11.21\%}$) | 1_155_170 ($\textcolor{green}{-11.58\%}$) |
btree | 194_059 ($\textcolor{green}{-17.52\%}$) | 1_934_621_105 ($\textcolor{green}{-10.84\%}$) | 8_157_968 | 883_615 ($\textcolor{green}{-12.24\%}$) | 1_773_826 ($\textcolor{green}{-11.31\%}$) | 956_678 ($\textcolor{green}{-12.19\%}$) |
zhenya_hashmap | 157_997 ($\textcolor{green}{-16.46\%}$) | 1_648_201_768 ($\textcolor{green}{-11.16\%}$) | 9_301_800 | 649_931 ($\textcolor{green}{-12.91\%}$) | 1_454_771 ($\textcolor{green}{-11.92\%}$) | 654_626 ($\textcolor{green}{-13.02\%}$) |
btreemap_rs | 422_180 ($\textcolor{green}{-18.20\%}$) | 122_486_096 ($\textcolor{green}{-1.06\%}$) | 1_638_400 | 60_360 ($\textcolor{red}{1.07\%}$) | 138_077 ($\textcolor{green}{-1.56\%}$) | 61_505 ($\textcolor{green}{-0.94\%}$) |
hashmap_rs | 411_353 ($\textcolor{green}{-18.41\%}$) | 52_292_656 ($\textcolor{green}{-1.77\%}$) | 1_835_008 | 20_648 ($\textcolor{green}{-3.34\%}$) | 62_156 ($\textcolor{green}{-2.57\%}$) | 21_930 ($\textcolor{green}{-3.72\%}$) |
binary_size | heapify 50k | mem | pop_min 50 | put 50 | |
---|---|---|---|---|---|
heap | 150_084 ($\textcolor{green}{-16.80\%}$) | 695_512_639 ($\textcolor{green}{-12.67\%}$) | 1_400_024 | 377_593 ($\textcolor{green}{-10.27\%}$) | 727_475 ($\textcolor{green}{-12.82\%}$) |
heap_rs | 390_095 ($\textcolor{green}{-17.90\%}$) | 4_978_816 ($\textcolor{green}{-1.25\%}$) | 819_200 | 52_862 ($\textcolor{green}{-1.31\%}$) | 21_741 ($\textcolor{green}{-2.42\%}$) |
binary_size | generate 10k | max mem | batch_get 50 | batch_put 50 | batch_remove 50 | |
---|---|---|---|---|---|---|
hashmap | 162_667 ($\textcolor{green}{-16.84\%}$) | 422_411_986 ($\textcolor{green}{-11.53\%}$) | 1_820_844 | 1_122_416 ($\textcolor{green}{-13.09\%}$) | 123_656_843 ($\textcolor{green}{-10.96\%}$) | 1_062_614 ($\textcolor{green}{-13.08\%}$) |
hashmap_rs | 411_353 ($\textcolor{green}{-18.41\%}$) | 10_772_672 ($\textcolor{green}{-1.75\%}$) | 950_272 | 19_979 ($\textcolor{green}{-3.37\%}$) | 61_484 ($\textcolor{green}{-2.56\%}$) | 20_872 ($\textcolor{green}{-3.67\%}$) |
imrc_hashmap_rs | 420_546 ($\textcolor{green}{-18.59\%}$) | 19_678_328 ($\textcolor{green}{-0.92\%}$) | 1_572_864 | 31_170 ($\textcolor{green}{-2.04\%}$) | 118_660 ($\textcolor{green}{-1.29\%}$) | 37_893 ($\textcolor{green}{-0.07\%}$) |
movm_rs | 1_704_006 ($\textcolor{green}{-16.27\%}$) | 1_097_944_086 ($\textcolor{green}{-0.08\%}$) | 2_654_208 | 2_716_088 ($\textcolor{green}{-1.02\%}$) | 6_930_281 ($\textcolor{green}{-0.19\%}$) | 5_411_168 ($\textcolor{green}{-0.10\%}$) |
movm_dynamic_rs | 1_868_114 ($\textcolor{green}{-17.04\%}$) | 551_513_510 ($\textcolor{green}{-0.73\%}$) | 2_129_920 | 2_170_192 ($\textcolor{green}{-0.76\%}$) | 2_980_021 ($\textcolor{green}{-1.00\%}$) | 2_146_546 ($\textcolor{green}{-0.90\%}$) |
pub_binary_size | sub_binary_size | subscribe_caller | subscribe_callee | publish_caller | publish_callee | |
---|---|---|---|---|---|---|
Motoko | 142_143 ($\textcolor{green}{-17.24\%}$) | 129_663 ($\textcolor{green}{-17.36\%}$) | 18_768 ($\textcolor{green}{-4.45\%}$) | 8_564 ($\textcolor{green}{-6.35\%}$) | 14_734 ($\textcolor{green}{-5.16\%}$) | 3_720 ($\textcolor{green}{-7.02\%}$) |
Rust | 459_879 ($\textcolor{green}{-18.46\%}$) | 513_055 ($\textcolor{green}{-26.31\%}$) | 61_293 ($\textcolor{green}{-3.33\%}$) | 41_686 ($\textcolor{green}{-3.48\%}$) | 86_682 ($\textcolor{green}{-3.02\%}$) | 48_938 ($\textcolor{green}{-3.18\%}$) |
binary_size | init | transfer_token | submit_proposal | vote_proposal | |
---|---|---|---|---|---|
Motoko | 232_614 ($\textcolor{green}{-20.08\%}$) | 41_548 ($\textcolor{green}{-6.94\%}$) | 18_372 ($\textcolor{green}{-8.50\%}$) | 12_873 ($\textcolor{green}{-9.09\%}$) | 15_115 ($\textcolor{green}{-10.15\%}$) |
Rust | 734_143 ($\textcolor{green}{-22.27\%}$) | 526_210 ($\textcolor{green}{-2.91\%}$) | 99_189 ($\textcolor{green}{-3.20\%}$) | 122_212 ($\textcolor{green}{-2.91\%}$) | 134_838 ($\textcolor{green}{-2.86\%}$) |
binary_size | init | mint_token | transfer_token | |
---|---|---|---|---|
Motoko | 185_377 ($\textcolor{green}{-21.20\%}$) | 12_292 ($\textcolor{green}{-8.12\%}$) | 23_080 ($\textcolor{green}{-6.48\%}$) | 4_818 ($\textcolor{green}{-10.06\%}$) |
Rust | 775_133 ($\textcolor{green}{-22.34\%}$) | 142_951 ($\textcolor{green}{-2.85\%}$) | 370_840 ($\textcolor{green}{-2.72\%}$) | 92_651 ($\textcolor{green}{-2.95\%}$) |
generate 80k | max mem | batch_get 50 | batch_put 50 | batch_remove 50 | |
---|---|---|---|---|---|
default | 247_115_881 | 15_539_984 | 50 | 50 | 50 |
copying | 247_115_831 | 15_539_984 | 247_110_319 | 247_262_382 | 247_262_501 |
compacting | 409_365_425 | 15_539_984 | 308_339_012 | 348_775_445 | 352_663_118 |
generational | 624_423_107 | 15_540_260 | 57_009 | 1_390_483 | 1_060_163 |
Measure the cost of empty heartbeat and timer job.
setTimer
measures both thesetTimer(0)
method and the execution of empty job.setTimer
andcanister_global_timer
function. If it's not there, we may need to adjust the script.Heartbeat
Timer
Collection libraries
Measure different collection libraries written in both Motoko and Rust. The library names with
_rs
suffix are written in Rust; the rest are written in Motoko.We use the same random number generator with fixed seed to ensure that all collections contain the same elements, and the queries are exactly the same. Below we explain the measurements of each column in the table:
rts_max_live_size
aftergenerate
call; For Rust, it reports the Wasm's memory page * 32Kb.💎 Takeaways
O(10000 nlogn)
algorithm hitting the limit, while anO(n^2)
algorithm runs just fine.Map
Priority queue
MoVM
Publisher & Subscriber
Measure the cost of inter-canister calls from the Publisher & Subscriber example.
Sample Dapps
Measure the performance of some typical dapps:
heartbeat
disabled to make profiling easier. We have a separate benchmark to measure heartbeat performance.Basic DAO
DIP721 NFT
Motoko Garbage Collection
Measure Motoko garbage collection cost using the Triemap benchmark. The max mem column reports
rts_max_live_size
aftergenerate
call. The cycle cost numbers reported here are garbage collection cost only. Some flamegraphs are truncated due to the 2M log size limit.generate
will trigger the copying GC. The rest of the methods will not trigger GC.--force-gc --copying-gc
.--force-gc --compacting-gc
.--force-gc --generational-gc
.