diff --git a/Cargo.toml b/Cargo.toml index c5f4ef07..c9b6f79b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ version = "0.6.8" [dependencies] ic_principal = { version = "0.1.1", default-features = false } # An optional dependency to benchmark parts of the code. -canbench-rs = { version = "0.1.11", optional = true } +canbench-rs = { version = "0.1.12", optional = true } [dev-dependencies] candid.workspace = true diff --git a/canbench_results.csv b/canbench_results.csv new file mode 100644 index 00000000..dbf8034a --- /dev/null +++ b/canbench_results.csv @@ -0,0 +1,125 @@ +status,name,instructions,instructions %,heap_increase,heap_increase %,stable_memory_increase,stable_memory_increase % +,btreemap_contains_key_blob_4_1024,164495877,-0.91%,0,,0, +,btreemap_contains_key_blob_4_1024_v2,248921977,0.94%,0,,0, +,btreemap_get_blob_128_1024,876676182,0.61%,0,,0, +,btreemap_get_blob_128_1024_v2,953199881,0.08%,0,,0, +,btreemap_get_blob_16_1024,241470994,-2.18%,0,,0, +,btreemap_get_blob_16_1024_v2,320086039,-0.87%,0,,0, +,btreemap_get_blob_256_1024,1440152578,0.12%,0,,0, +,btreemap_get_blob_256_1024_v2,1524516290,0.13%,0,,0, +,btreemap_get_blob_32_1024,275141698,-1.77%,0,,0, +,btreemap_get_blob_32_1024_v2,353756221,-1.20%,0,,0, +,btreemap_get_blob_4_1024,182139496,-0.95%,0,,0, +,btreemap_get_blob_4_1024_v2,267339946,-0.40%,0,,0, +,btreemap_get_blob_512_1024,2573387979,-0.02%,0,,0, +,btreemap_get_blob_512_1024_v2,2653499228,0.02%,0,,0, +,btreemap_get_blob_512_1024_v2_mem_manager,2759852247,0.03%,0,,0, +,btreemap_get_blob_64_1024,521344804,-0.21%,0,,0, +,btreemap_get_blob_64_1024_v2,603758767,0.21%,0,,0, +,btreemap_get_blob_8_1024,212618950,-2.20%,0,,0, +,btreemap_get_blob_8_1024_v2,294121282,-1.86%,0,,0, +,btreemap_get_blob_8_u64,199845052,-0.66%,0,,0, +,btreemap_get_blob_8_u64_v2,289664167,-2.82%,0,,0, +,btreemap_get_u64_blob_8,173627473,-1.15%,0,,0, +,btreemap_get_u64_blob_8_v2,245312213,-1.86%,0,,0, +,btreemap_get_u64_u64,176661272,0.17%,0,,0, +,btreemap_get_u64_u64_v2,249218649,-2.90%,0,,0, +,btreemap_get_u64_u64_v2_mem_manager,329730573,-1.92%,0,,0, +,btreemap_insert_10mib_values,5235962440,0.00%,0,,3613,0.00% +,btreemap_insert_blob_1024_128,5098352751,-0.23%,0,,262,0.00% +,btreemap_insert_blob_1024_128_v2,5199218550,-0.04%,0,,196,0.00% +,btreemap_insert_blob_1024_16,5080607598,-0.63%,0,,241,0.00% +,btreemap_insert_blob_1024_16_v2,5187794378,-0.23%,0,,181,0.00% +,btreemap_insert_blob_1024_256,5125958119,-0.11%,0,,292,0.00% +,btreemap_insert_blob_1024_256_v2,5224501040,-0.01%,0,,219,0.00% +,btreemap_insert_blob_1024_32,5075547429,-0.40%,0,,239,0.00% +,btreemap_insert_blob_1024_32_v2,5185065640,-0.18%,0,,180,0.00% +,btreemap_insert_blob_1024_4,4977775085,-0.82%,0,,235,0.00% +,btreemap_insert_blob_1024_4_v2,5084891041,-0.25%,0,,176,0.00% +,btreemap_insert_blob_1024_512,5200292029,-0.11%,1,,348,0.00% +,btreemap_insert_blob_1024_512_v2,5299421985,-0.11%,0,,261,0.00% +,btreemap_insert_blob_1024_512_v2_mem_manager,5469551996,-0.10%,0,,256,0.00% +,btreemap_insert_blob_1024_64,5133691382,-0.31%,0,,250,0.00% +,btreemap_insert_blob_1024_64_v2,5242140512,-0.12%,0,,188,0.00% +,btreemap_insert_blob_1024_8,5065686056,-0.38%,0,,237,0.00% +,btreemap_insert_blob_1024_8_v2,5174504738,-0.24%,0,,178,0.00% +,btreemap_insert_blob_128_1024,1276472811,0.29%,0,,260,0.00% +,btreemap_insert_blob_128_1024_v2,1378788105,0.43%,0,,195,0.00% +,btreemap_insert_blob_16_1024,634307113,-0.48%,0,,215,0.00% +,btreemap_insert_blob_16_1024_v2,733723555,0.24%,0,,161,0.00% +,btreemap_insert_blob_256_1024,1860540926,0.06%,0,,292,0.00% +,btreemap_insert_blob_256_1024_v2,1967548428,0.52%,0,,219,0.00% +,btreemap_insert_blob_32_1024,670121076,-0.34%,0,,230,0.00% +,btreemap_insert_blob_32_1024_v2,773022814,0.43%,0,,173,0.00% +,btreemap_insert_blob_4_1024,494994994,-0.38%,0,,123,0.00% +,btreemap_insert_blob_4_1024_v2,592951465,-0.08%,0,,92,0.00% +,btreemap_insert_blob_512_1024,3002862489,-0.25%,0,,351,0.00% +,btreemap_insert_blob_512_1024_v2,3105965075,0.06%,0,,263,0.00% +,btreemap_insert_blob_64_1024,919414593,-0.01%,0,,245,0.00% +,btreemap_insert_blob_64_1024_v2,1020998986,0.55%,0,,183,0.00% +,btreemap_insert_blob_8_1024,605636927,-0.29%,0,,183,0.00% +,btreemap_insert_blob_8_1024_v2,708696031,-0.05%,0,,138,0.00% +,btreemap_insert_blob_8_u64,330055088,0.06%,0,,6,0.00% +,btreemap_insert_blob_8_u64_v2,440988930,0.07%,0,,4,0.00% +,btreemap_insert_u64_blob_8,339864719,0.12%,0,,7,0.00% +,btreemap_insert_u64_blob_8_v2,422835585,0.69%,0,,5,0.00% +,btreemap_insert_u64_u64,345025209,0.01%,0,,7,0.00% +,btreemap_insert_u64_u64_v2,431645530,0.73%,0,,6,0.00% +,btreemap_insert_u64_u64_v2_mem_manager,560976863,0.50%,0,,0, +,btreemap_iter_10mib_values,11407368,-0.00%,0,,0, +,btreemap_iter_count_10mib_values,491365,2.95%,0,,0, +,btreemap_iter_count_small_values,9443266,0.01%,0,,0, +,btreemap_iter_rev_10mib_values,11404353,-0.00%,0,,0, +,btreemap_iter_rev_small_values,14975879,0.00%,0,,0, +,btreemap_iter_small_values,15000850,0.15%,0,,0, +,btreemap_keys_10mib_values,464540,-0.00%,0,,0, +,btreemap_keys_rev_10mib_values,464165,-0.01%,0,,0, +,btreemap_keys_rev_small_values,9654062,0.00%,0,,0, +,btreemap_keys_small_values,9528327,0.23%,0,,0, +,btreemap_read_every_third_value_from_range,84833060,0.78%,0,,0, +,btreemap_read_keys_from_range,84873064,0.78%,0,,0, +,btreemap_remove_blob_128_1024,1575050534,0.08%,0,,0, +,btreemap_remove_blob_128_1024_v2,1721504123,0.28%,0,,0, +,btreemap_remove_blob_16_1024,755252791,-0.27%,0,,0, +,btreemap_remove_blob_16_1024_v2,895690307,0.06%,0,,0, +,btreemap_remove_blob_256_1024,2279810995,0.07%,0,,0, +,btreemap_remove_blob_256_1024_v2,2427184450,0.42%,0,,0, +,btreemap_remove_blob_32_1024,825632231,-0.14%,0,,0, +,btreemap_remove_blob_32_1024_v2,965884147,0.00%,0,,0, +,btreemap_remove_blob_4_1024,485805538,-0.03%,0,,0, +,btreemap_remove_blob_4_1024_v2,600161724,0.10%,0,,0, +,btreemap_remove_blob_512_1024,3738145419,-0.27%,0,,0, +,btreemap_remove_blob_512_1024_v2,3883681704,0.16%,0,,0, +,btreemap_remove_blob_64_1024,1139970828,-0.01%,0,,0, +,btreemap_remove_blob_64_1024_v2,1283145072,0.25%,0,,0, +,btreemap_remove_blob_8_1024,642836148,-0.19%,0,,0, +,btreemap_remove_blob_8_1024_v2,775037862,-0.13%,0,,0, +,btreemap_remove_blob_8_u64,433944769,-0.08%,0,,0, +,btreemap_remove_blob_8_u64_v2,579958230,-0.57%,0,,0, +,btreemap_remove_u64_blob_8,485913516,0.21%,0,,0, +,btreemap_remove_u64_blob_8_v2,597538858,-0.46%,0,,0, +,btreemap_remove_u64_u64,499266505,0.24%,0,,0, +,btreemap_remove_u64_u64_v2,619109964,-0.59%,0,,0, +,btreemap_values_10mib_values,11406848,-0.00%,0,,0, +,btreemap_values_rev_10mib_values,11403833,-0.00%,0,,0, +,btreemap_values_rev_small_values,14949875,0.00%,0,,0, +,btreemap_values_small_values,14974846,0.15%,0,,0, +,memory_manager_baseline,1176577076,0.00%,0,,8000,0.00% +,memory_manager_grow,346537961,0.00%,2,0.00%,32000,0.00% +,memory_manager_overhead,1181962837,0.00%,0,,8320,0.00% +,vec_get_blob_128,19246658,-0.31%,0,,0, +,vec_get_blob_16,6345942,-0.88%,0,,0, +,vec_get_blob_32,7063501,-0.82%,0,,0, +,vec_get_blob_4,4804323,-0.93%,0,,0, +,vec_get_blob_4_mem_manager,7171673,-0.63%,0,,0, +,vec_get_blob_64,11310940,-0.52%,0,,0, +,vec_get_blob_64_mem_manager,13651088,-0.43%,0,,0, +,vec_get_blob_8,5620865,-0.93%,0,,0, +,vec_get_u64,5270302,-1.13%,0,,0, +,vec_insert_blob_128,4131421,0.00%,0,,19,0.00% +,vec_insert_blob_16,3296224,0.00%,0,,2,0.00% +,vec_insert_blob_32,3415464,0.00%,0,,5,0.00% +,vec_insert_blob_4,3207465,0.00%,0,,0, +,vec_insert_blob_64,3655801,0.00%,0,,9,0.00% +,vec_insert_blob_8,3236886,0.00%,0,,1,0.00% +,vec_insert_u64,5859516,-1.01%,0,,1,0.00% diff --git a/canbench_results.yml b/canbench_results.yml index 2ad468d5..855a6a71 100644 --- a/canbench_results.yml +++ b/canbench_results.yml @@ -1,631 +1,631 @@ benches: btreemap_contains_key_blob_4_1024: total: - instructions: 166001911 + instructions: 164495877 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_contains_key_blob_4_1024_v2: total: - instructions: 246601947 + instructions: 248921977 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_128_1024: total: - instructions: 871377872 + instructions: 876676182 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_128_1024_v2: total: - instructions: 952392228 + instructions: 953199881 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_16_1024: total: - instructions: 246862995 + instructions: 241470994 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_16_1024_v2: total: - instructions: 322886242 + instructions: 320086039 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_256_1024: total: - instructions: 1438374028 + instructions: 1440152578 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_256_1024_v2: total: - instructions: 1522510069 + instructions: 1524516290 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_32_1024: total: - instructions: 280106749 + instructions: 275141698 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_32_1024_v2: total: - instructions: 358059329 + instructions: 353756221 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_4_1024: total: - instructions: 183878297 + instructions: 182139496 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_4_1024_v2: total: - instructions: 268405505 + instructions: 267339946 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_512_1024: total: - instructions: 2574022254 + instructions: 2573387979 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_512_1024_v2: total: - instructions: 2652896322 + instructions: 2653499228 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_512_1024_v2_mem_manager: total: - instructions: 2758935787 + instructions: 2759852247 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_64_1024: total: - instructions: 522452991 + instructions: 521344804 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_64_1024_v2: total: - instructions: 602470697 + instructions: 603758767 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_8_1024: total: - instructions: 217400954 + instructions: 212618950 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_8_1024_v2: total: - instructions: 299709226 + instructions: 294121282 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_8_u64: total: - instructions: 201178254 + instructions: 199845052 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_blob_8_u64_v2: total: - instructions: 298067604 + instructions: 289664167 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_u64_blob_8: total: - instructions: 175651037 + instructions: 173627473 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_u64_blob_8_v2: total: - instructions: 249967565 + instructions: 245312213 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_u64_u64: total: - instructions: 176359012 + instructions: 176661272 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_u64_u64_v2: total: - instructions: 256656266 + instructions: 249218649 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_get_u64_u64_v2_mem_manager: total: - instructions: 336201045 + instructions: 329730573 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_insert_10mib_values: total: - instructions: 5235943961 + instructions: 5235962440 heap_increase: 0 stable_memory_increase: 3613 scopes: {} btreemap_insert_blob_1024_128: total: - instructions: 5110208593 + instructions: 5098352751 heap_increase: 0 stable_memory_increase: 262 scopes: {} btreemap_insert_blob_1024_128_v2: total: - instructions: 5201453100 + instructions: 5199218550 heap_increase: 0 stable_memory_increase: 196 scopes: {} btreemap_insert_blob_1024_16: total: - instructions: 5112815038 + instructions: 5080607598 heap_increase: 0 stable_memory_increase: 241 scopes: {} btreemap_insert_blob_1024_16_v2: total: - instructions: 5199674897 + instructions: 5187794378 heap_increase: 0 stable_memory_increase: 181 scopes: {} btreemap_insert_blob_1024_256: total: - instructions: 5131549882 + instructions: 5125958119 heap_increase: 0 stable_memory_increase: 292 scopes: {} btreemap_insert_blob_1024_256_v2: total: - instructions: 5225231848 + instructions: 5224501040 heap_increase: 0 stable_memory_increase: 219 scopes: {} btreemap_insert_blob_1024_32: total: - instructions: 5096055369 + instructions: 5075547429 heap_increase: 0 stable_memory_increase: 239 scopes: {} btreemap_insert_blob_1024_32_v2: total: - instructions: 5194253455 + instructions: 5185065640 heap_increase: 0 stable_memory_increase: 180 scopes: {} btreemap_insert_blob_1024_4: total: - instructions: 5018854334 + instructions: 4977775085 heap_increase: 0 stable_memory_increase: 235 scopes: {} btreemap_insert_blob_1024_4_v2: total: - instructions: 5097737990 + instructions: 5084891041 heap_increase: 0 stable_memory_increase: 176 scopes: {} btreemap_insert_blob_1024_512: total: - instructions: 5205867924 - heap_increase: 0 + instructions: 5200292029 + heap_increase: 1 stable_memory_increase: 348 scopes: {} btreemap_insert_blob_1024_512_v2: total: - instructions: 5305383655 + instructions: 5299421985 heap_increase: 0 stable_memory_increase: 261 scopes: {} btreemap_insert_blob_1024_512_v2_mem_manager: total: - instructions: 5474930162 + instructions: 5469551996 heap_increase: 0 stable_memory_increase: 256 scopes: {} btreemap_insert_blob_1024_64: total: - instructions: 5149718328 + instructions: 5133691382 heap_increase: 0 stable_memory_increase: 250 scopes: {} btreemap_insert_blob_1024_64_v2: total: - instructions: 5248619760 + instructions: 5242140512 heap_increase: 0 stable_memory_increase: 188 scopes: {} btreemap_insert_blob_1024_8: total: - instructions: 5084892193 + instructions: 5065686056 heap_increase: 0 stable_memory_increase: 237 scopes: {} btreemap_insert_blob_1024_8_v2: total: - instructions: 5187073263 + instructions: 5174504738 heap_increase: 0 stable_memory_increase: 178 scopes: {} btreemap_insert_blob_128_1024: total: - instructions: 1272772874 + instructions: 1276472811 heap_increase: 0 stable_memory_increase: 260 scopes: {} btreemap_insert_blob_128_1024_v2: total: - instructions: 1372830782 + instructions: 1378788105 heap_increase: 0 stable_memory_increase: 195 scopes: {} btreemap_insert_blob_16_1024: total: - instructions: 637364736 + instructions: 634307113 heap_increase: 0 stable_memory_increase: 215 scopes: {} btreemap_insert_blob_16_1024_v2: total: - instructions: 731987999 + instructions: 733723555 heap_increase: 0 stable_memory_increase: 161 scopes: {} btreemap_insert_blob_256_1024: total: - instructions: 1859383657 + instructions: 1860540926 heap_increase: 0 stable_memory_increase: 292 scopes: {} btreemap_insert_blob_256_1024_v2: total: - instructions: 1957371233 + instructions: 1967548428 heap_increase: 0 stable_memory_increase: 219 scopes: {} btreemap_insert_blob_32_1024: total: - instructions: 672421095 + instructions: 670121076 heap_increase: 0 stable_memory_increase: 230 scopes: {} btreemap_insert_blob_32_1024_v2: total: - instructions: 769687258 + instructions: 773022814 heap_increase: 0 stable_memory_increase: 173 scopes: {} btreemap_insert_blob_4_1024: total: - instructions: 496883691 + instructions: 494994994 heap_increase: 0 stable_memory_increase: 123 scopes: {} btreemap_insert_blob_4_1024_v2: total: - instructions: 593431891 + instructions: 592951465 heap_increase: 0 stable_memory_increase: 92 scopes: {} btreemap_insert_blob_512_1024: total: - instructions: 3010338686 + instructions: 3002862489 heap_increase: 0 stable_memory_increase: 351 scopes: {} btreemap_insert_blob_512_1024_v2: total: - instructions: 3104211392 + instructions: 3105965075 heap_increase: 0 stable_memory_increase: 263 scopes: {} btreemap_insert_blob_64_1024: total: - instructions: 919481835 + instructions: 919414593 heap_increase: 0 stable_memory_increase: 245 scopes: {} btreemap_insert_blob_64_1024_v2: total: - instructions: 1015421433 + instructions: 1020998986 heap_increase: 0 stable_memory_increase: 183 scopes: {} btreemap_insert_blob_8_1024: total: - instructions: 607378396 + instructions: 605636927 heap_increase: 0 stable_memory_increase: 183 scopes: {} btreemap_insert_blob_8_1024_v2: total: - instructions: 709076144 + instructions: 708696031 heap_increase: 0 stable_memory_increase: 138 scopes: {} btreemap_insert_blob_8_u64: total: - instructions: 329873548 + instructions: 330055088 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_insert_blob_8_u64_v2: total: - instructions: 440675672 + instructions: 440988930 heap_increase: 0 stable_memory_increase: 4 scopes: {} btreemap_insert_u64_blob_8: total: - instructions: 339462674 + instructions: 339864719 heap_increase: 0 stable_memory_increase: 7 scopes: {} btreemap_insert_u64_blob_8_v2: total: - instructions: 419939410 + instructions: 422835585 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_insert_u64_u64: total: - instructions: 345002937 + instructions: 345025209 heap_increase: 0 stable_memory_increase: 7 scopes: {} btreemap_insert_u64_u64_v2: total: - instructions: 428515075 + instructions: 431645530 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_insert_u64_u64_v2_mem_manager: total: - instructions: 558164116 + instructions: 560976863 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_iter_10mib_values: total: - instructions: 11407375 + instructions: 11407368 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_iter_count_10mib_values: total: - instructions: 477290 + instructions: 491365 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_iter_count_small_values: total: - instructions: 9442534 + instructions: 9443266 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_iter_rev_10mib_values: total: - instructions: 11404378 + instructions: 11404353 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_iter_rev_small_values: total: - instructions: 14975518 + instructions: 14975879 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_iter_small_values: total: - instructions: 14978611 + instructions: 15000850 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_keys_10mib_values: total: - instructions: 464547 + instructions: 464540 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_keys_rev_10mib_values: total: - instructions: 464190 + instructions: 464165 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_keys_rev_small_values: total: - instructions: 9653701 + instructions: 9654062 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_keys_small_values: total: - instructions: 9506088 + instructions: 9528327 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_read_every_third_value_from_range: total: - instructions: 84178399 + instructions: 84833060 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_read_keys_from_range: total: - instructions: 84218403 + instructions: 84873064 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_128_1024: total: - instructions: 1573792197 + instructions: 1575050534 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_128_1024_v2: total: - instructions: 1716743733 + instructions: 1721504123 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_16_1024: total: - instructions: 757326757 + instructions: 755252791 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_16_1024_v2: total: - instructions: 895123689 + instructions: 895690307 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_256_1024: total: - instructions: 2278298539 + instructions: 2279810995 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_256_1024_v2: total: - instructions: 2416985342 + instructions: 2427184450 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_32_1024: total: - instructions: 826755312 + instructions: 825632231 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_32_1024_v2: total: - instructions: 965860173 + instructions: 965884147 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_4_1024: total: - instructions: 485954031 + instructions: 485805538 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_4_1024_v2: total: - instructions: 599544997 + instructions: 600161724 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_512_1024: total: - instructions: 3748097651 + instructions: 3738145419 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_512_1024_v2: total: - instructions: 3877288521 + instructions: 3883681704 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_64_1024: total: - instructions: 1140140271 + instructions: 1139970828 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_64_1024_v2: total: - instructions: 1279997559 + instructions: 1283145072 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_8_1024: total: - instructions: 644037223 + instructions: 642836148 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_8_1024_v2: total: - instructions: 776025357 + instructions: 775037862 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_8_u64: total: - instructions: 434301327 + instructions: 433944769 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_blob_8_u64_v2: total: - instructions: 583272060 + instructions: 579958230 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_u64_blob_8: total: - instructions: 484889535 + instructions: 485913516 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_u64_blob_8_v2: total: - instructions: 600284021 + instructions: 597538858 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_u64_u64: total: - instructions: 498062638 + instructions: 499266505 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_remove_u64_u64_v2: total: - instructions: 622756309 + instructions: 619109964 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_values_10mib_values: total: - instructions: 11406855 + instructions: 11406848 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_values_rev_10mib_values: total: - instructions: 11403858 + instructions: 11403833 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_values_rev_small_values: total: - instructions: 14949514 + instructions: 14949875 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_values_small_values: total: - instructions: 14952607 + instructions: 14974846 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -637,67 +637,67 @@ benches: scopes: {} memory_manager_grow: total: - instructions: 346536492 + instructions: 346537961 heap_increase: 2 stable_memory_increase: 32000 scopes: {} memory_manager_overhead: total: - instructions: 1181962535 + instructions: 1181962837 heap_increase: 0 stable_memory_increase: 8320 scopes: {} vec_get_blob_128: total: - instructions: 19306238 + instructions: 19246658 heap_increase: 0 stable_memory_increase: 0 scopes: {} vec_get_blob_16: total: - instructions: 6402222 + instructions: 6345942 heap_increase: 0 stable_memory_increase: 0 scopes: {} vec_get_blob_32: total: - instructions: 7121653 + instructions: 7063501 heap_increase: 0 stable_memory_increase: 0 scopes: {} vec_get_blob_4: total: - instructions: 4849623 + instructions: 4804323 heap_increase: 0 stable_memory_increase: 0 scopes: {} vec_get_blob_4_mem_manager: total: - instructions: 7216973 + instructions: 7171673 heap_increase: 0 stable_memory_increase: 0 scopes: {} vec_get_blob_64: total: - instructions: 11370052 + instructions: 11310940 heap_increase: 0 stable_memory_increase: 0 scopes: {} vec_get_blob_64_mem_manager: total: - instructions: 13710200 + instructions: 13651088 heap_increase: 0 stable_memory_increase: 0 scopes: {} vec_get_blob_8: total: - instructions: 5673869 + instructions: 5620865 heap_increase: 0 stable_memory_increase: 0 scopes: {} vec_get_u64: total: - instructions: 5330302 + instructions: 5270302 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -739,8 +739,8 @@ benches: scopes: {} vec_insert_u64: total: - instructions: 5919429 + instructions: 5859516 heap_increase: 0 stable_memory_increase: 1 scopes: {} -version: 0.1.11 +version: 0.1.12 diff --git a/scripts/ci_download_canbench_artifacts.sh b/scripts/ci_download_canbench_artifacts.sh index 6b5d2b46..d866fc9d 100644 --- a/scripts/ci_download_canbench_artifacts.sh +++ b/scripts/ci_download_canbench_artifacts.sh @@ -1,29 +1,29 @@ #!/usr/bin/env bash set -Eexuo pipefail -# Identifies the benchmarks provided in the artifacts and outputs them. +# Collects benchmark results from artifact files and outputs them as a JSON array +# to be used in a GitHub Actions matrix. json_array="[" -# Loop through each file with prefix "canbench_result_" in the current directory + +# Loop through each directory matching the prefix "canbench_result_" for file in canbench_result_*; do -if [ -e "$file" ]; then # Check if the file exists. - # Read the content of the file, escaping double quotes and adding escaped newlines - content=$(<"$file/$file" sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}' | sed '$ s/\\n$//') + if [ -e "$file" ]; then + # Read the contents of the result file, escape double quotes, and format with escaped newlines + content=$(<"$file/$file" sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}' | sed '$ s/\\n$//') - # Construct a JSON object for the current file with "title" and "result" keys - json_object="{\"title\":\"$file\",\"result\":\"$content\"}," + # Construct a JSON object for the current result + json_object="{\"title\":\"$file\",\"result\":\"$content\"}," - # Append the JSON object to the array string - json_array+="$json_object" -fi + # Append it to the array + json_array+="$json_object" + fi done -# Remove the trailing comma from the JSON array string +# Remove the trailing comma and close the JSON array json_array=${json_array%,} - -# Close the JSON array string json_array+="]" -# Output the benchmarks and PR number to be used by the next job. +# Output the benchmark matrix and PR number to be used by the next job echo "matrix={\"benchmark\": $json_array}" >> "$GITHUB_OUTPUT" echo "pr_number=$(cat ./pr_number/pr_number)" >> "$GITHUB_OUTPUT" diff --git a/scripts/ci_run_benchmark.sh b/scripts/ci_run_benchmark.sh index eff2b45e..ac8dbc53 100644 --- a/scripts/ci_run_benchmark.sh +++ b/scripts/ci_run_benchmark.sh @@ -1,19 +1,19 @@ #!/usr/bin/env bash set -Eexuo pipefail -# Script that runs `canbench` at a given directory and outputs a comment -# that is intended to be posted on the pull request. +# This script runs `canbench` in a given directory and outputs a comment +# intended to be posted on the pull request. # Path to run `canbench` from. CANISTER_PATH=$1 -# The name of the job in CI +# The name of the CI job. CANBENCH_JOB_NAME=$2 -# Must match the file specified in the github action. +# Must match the file path specified in the GitHub Action. COMMENT_MESSAGE_PATH=/tmp/canbench_result_${CANBENCH_JOB_NAME} -# Github CI is expected to have the main branch checked out in this folder. +# GitHub CI is expected to have the main branch checked out in this folder. MAIN_BRANCH_DIR=_canbench_main_branch CANBENCH_OUTPUT=/tmp/canbench_output.txt @@ -21,28 +21,28 @@ CANBENCH_OUTPUT=/tmp/canbench_output.txt CANBENCH_RESULTS_FILE="$CANISTER_PATH/canbench_results.yml" MAIN_BRANCH_RESULTS_FILE="$MAIN_BRANCH_DIR/$CANBENCH_RESULTS_FILE" -# Install canbench -cargo install --version 0.1.11 canbench +# Install canbench. +cargo install --version 0.1.12 canbench -# Verify that canbench results are available. +# Verify that the canbench results file exists. if [ ! -f "$CANBENCH_RESULTS_FILE" ]; then - echo "$CANBENCH_RESULTS_FILE not found. Did you forget to run \`canbench --persist\`?"; + echo "$CANBENCH_RESULTS_FILE not found. Did you forget to run \`canbench --persist\`?" exit 1 fi -# Detect if canbench results file is up to date. +# Check if the canbench results file is up to date. pushd "$CANISTER_PATH" canbench --less-verbose > $CANBENCH_OUTPUT if grep -q "(regress\|(improved by \|(new)" "$CANBENCH_OUTPUT"; then UPDATED_MSG="**❌ \`$CANBENCH_RESULTS_FILE\` is not up to date** - If the performance change is expected, run \`canbench --persist\` to save the updated benchmark results."; + If the performance change is expected, run \`canbench --persist\` to update the benchmark results." - # canbench results file not up to date. Fail the job. + # Results are outdated; fail the job. echo "EXIT_STATUS=1" >> "$GITHUB_ENV" else UPDATED_MSG="**✅ \`$CANBENCH_RESULTS_FILE\` is up to date**"; - # canbench results file is up to date. The job succeeds. + # Results are up to date; job succeeds. echo "EXIT_STATUS=0" >> "$GITHUB_ENV" fi popd @@ -54,17 +54,17 @@ time=$(date -u +"%Y-%m-%d %H:%M:%S UTC") # Print output with correct formatting echo "# \`canbench\` 🏋 (dir: $CANISTER_PATH) $commit_hash $time" > "$COMMENT_MESSAGE_PATH" -# Detect if there are performance changes relative to the main branch. +# Check for performance changes relative to the main branch. if [ -f "$MAIN_BRANCH_RESULTS_FILE" ]; then - # Move the results of the main branch into the current branch. + # Replace the current results with the main branch results. mv "$MAIN_BRANCH_RESULTS_FILE" "$CANBENCH_RESULTS_FILE" - # Run canbench to compare result to main branch. + # Run canbench to compare results with the main branch. pushd "$CANISTER_PATH" - canbench --less-verbose > "$CANBENCH_OUTPUT" + canbench --less-verbose --hide-results --show-summary > "$CANBENCH_OUTPUT" popd - # Add emojis for visualization (as of December 2024, Github does not support colored text) + # Append markers to individual benchmark results awk ' /\(improved / { print $0, "đŸŸĸ"; next } /\(regressed / { print $0, "🔴"; next } @@ -79,7 +79,7 @@ if [ -f "$MAIN_BRANCH_RESULTS_FILE" ]; then echo -e "${MESSAGE:-**â„šī¸ No significant performance changes detected 👍**}" >> "$COMMENT_MESSAGE_PATH" fi -## Add the output of canbench to the file. +# Append the update status and benchmark output to the comment. { echo "$UPDATED_MSG" echo ""