diff --git a/canbench_results.yml b/canbench_results.yml index 0c78e42d..d87b0611 100644 --- a/canbench_results.yml +++ b/canbench_results.yml @@ -1,1711 +1,1711 @@ benches: btreemap_v2_contains_10mib_values: total: - instructions: 142213004 + instructions: 142229058 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob8_u64: total: - instructions: 277713087 + instructions: 292071256 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_1024_128: total: - instructions: 4897884819 + instructions: 3004678141 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_128_128: total: - instructions: 925983020 + instructions: 665016023 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_16_128: total: - instructions: 304185180 + instructions: 299266114 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_256_128: total: - instructions: 1482592583 + instructions: 985524245 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_1024: total: - instructions: 334889492 + instructions: 317750197 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128: total: - instructions: 332336378 + instructions: 317486525 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_16: total: - instructions: 336647532 + instructions: 316913507 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_256: total: - instructions: 336952134 + instructions: 319375798 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_32: total: - instructions: 337767804 + instructions: 321175428 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_4: total: - instructions: 333734209 + instructions: 317302163 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_512: total: - instructions: 332809414 + instructions: 317454763 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_64: total: - instructions: 335145674 + instructions: 320828457 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_8: total: - instructions: 334699459 + instructions: 318450047 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_4_128: total: - instructions: 244876846 + instructions: 264127393 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_512_128: total: - instructions: 2624677444 + instructions: 1657176786 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_64_128: total: - instructions: 584178824 + instructions: 400794429 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_8_128: total: - instructions: 268359561 + instructions: 280164328 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_blob8: total: - instructions: 234897323 + instructions: 249345668 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64: total: - instructions: 236421608 + instructions: 255212854 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_vec8: total: - instructions: 234897338 + instructions: 249345668 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec8_u64: total: - instructions: 366491431 + instructions: 331414697 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_1024_128: total: - instructions: 2875641971 + instructions: 1843552548 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_128_128: total: - instructions: 698056573 + instructions: 559068813 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_16_128: total: - instructions: 430496510 + instructions: 379282562 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_256_128: total: - instructions: 1220085542 + instructions: 913001425 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_1024: total: - instructions: 573798539 + instructions: 512588096 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128: total: - instructions: 488603839 + instructions: 433820781 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_16: total: - instructions: 408307710 + instructions: 363297614 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_256: total: - instructions: 521878485 + instructions: 441973791 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_32: total: - instructions: 408806200 + instructions: 363312712 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_4: total: - instructions: 407179812 + instructions: 362491802 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_512: total: - instructions: 536998195 + instructions: 477204790 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_64: total: - instructions: 463602926 + instructions: 403341248 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_8: total: - instructions: 407102811 + instructions: 362531723 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_4_128: total: - instructions: 397153848 + instructions: 352494755 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_512_128: total: - instructions: 1812299060 + instructions: 1272734638 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_64_128: total: - instructions: 594729377 + instructions: 508397924 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_8_128: total: - instructions: 388847731 + instructions: 350968224 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_10mib_values: total: - instructions: 1227472657 + instructions: 1227489035 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob8_u64: total: - instructions: 297139911 + instructions: 304816032 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_1024_128: total: - instructions: 4953924210 + instructions: 3144320444 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_128_128: total: - instructions: 947186495 + instructions: 698826651 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_16_128: total: - instructions: 317354417 + instructions: 313298866 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_256_128: total: - instructions: 1507431266 + instructions: 1032439290 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_1024: total: - instructions: 353756221 + instructions: 338180223 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128: total: - instructions: 345894163 + instructions: 332624198 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_16: total: - instructions: 346953462 + instructions: 328919681 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_256: total: - instructions: 351580221 + instructions: 335563422 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_32: total: - instructions: 348889561 + instructions: 333781460 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_4: total: - instructions: 343473664 + instructions: 328246778 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_512: total: - instructions: 348929751 + instructions: 335192871 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_64: total: - instructions: 347119635 + instructions: 334932529 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_8: total: - instructions: 345315038 + instructions: 329900204 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_4_128: total: - instructions: 257370621 + instructions: 276743152 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_512_128: total: - instructions: 2659912132 + instructions: 1734963607 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_64_128: total: - instructions: 601774814 + instructions: 425486333 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_8_128: total: - instructions: 281640219 + instructions: 293940212 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_blob8: total: - instructions: 245362209 + instructions: 260251406 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64: total: - instructions: 249268645 + instructions: 268110583 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_vec8: total: - instructions: 246137433 + instructions: 261065188 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec8_u64: total: - instructions: 376858286 + instructions: 343885017 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_1024_128: total: - instructions: 2921959775 + instructions: 1892468068 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_128_128: total: - instructions: 710827388 + instructions: 571871925 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_16_128: total: - instructions: 440398211 + instructions: 390610021 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_256_128: total: - instructions: 1233367092 + instructions: 926323429 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_1024: total: - instructions: 606431114 + instructions: 555478534 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128: total: - instructions: 498908637 + instructions: 444489523 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_16: total: - instructions: 416949497 + instructions: 371411562 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_256: total: - instructions: 539821398 + instructions: 460059095 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_32: total: - instructions: 417020079 + instructions: 371559358 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_4: total: - instructions: 415119023 + instructions: 370813831 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_512: total: - instructions: 558783250 + instructions: 499706941 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_64: total: - instructions: 472181771 + instructions: 412299789 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_8: total: - instructions: 415079885 + instructions: 370858341 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_4_128: total: - instructions: 407056995 + instructions: 363440040 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_512_128: total: - instructions: 1825704224 + instructions: 1285923842 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_64_128: total: - instructions: 606201847 + instructions: 519684483 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_8_128: total: - instructions: 398653757 + instructions: 361789415 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_insert_10mib_values: total: - instructions: 5235944819 + instructions: 5236020394 heap_increase: 322 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: - instructions: 440868627 + instructions: 501716659 heap_increase: 0 stable_memory_increase: 4 scopes: {} btreemap_v2_insert_blob_1024_128: total: - instructions: 5104008235 + instructions: 4298409341 heap_increase: 0 stable_memory_increase: 196 scopes: {} btreemap_v2_insert_blob_128_128: total: - instructions: 1133684047 + instructions: 1062334322 heap_increase: 0 stable_memory_increase: 46 scopes: {} btreemap_v2_insert_blob_16_128: total: - instructions: 494767994 + instructions: 550033663 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_blob_256_128: total: - instructions: 1683872591 + instructions: 1517044762 heap_increase: 0 stable_memory_increase: 67 scopes: {} btreemap_v2_insert_blob_32_1024: total: - instructions: 687122501 + instructions: 732784071 heap_increase: 0 stable_memory_increase: 173 scopes: {} btreemap_v2_insert_blob_32_128: total: - instructions: 529123151 + instructions: 577281316 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_16: total: - instructions: 508434275 + instructions: 555235014 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: - instructions: 560318880 + instructions: 603441750 heap_increase: 0 stable_memory_increase: 49 scopes: {} btreemap_v2_insert_blob_32_32: total: - instructions: 514031722 + instructions: 560817016 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_32_4: total: - instructions: 496606799 + instructions: 544048239 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: - instructions: 597566608 + instructions: 645074828 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_blob_32_64: total: - instructions: 519519045 + instructions: 567941552 heap_increase: 0 stable_memory_increase: 18 scopes: {} btreemap_v2_insert_blob_32_8: total: - instructions: 503751175 + instructions: 549794717 heap_increase: 0 stable_memory_increase: 9 scopes: {} btreemap_v2_insert_blob_4_128: total: - instructions: 410411927 + instructions: 477592446 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_512_128: total: - instructions: 2855055481 + instructions: 2459054925 heap_increase: 0 stable_memory_increase: 111 scopes: {} btreemap_v2_insert_blob_64_128: total: - instructions: 777536947 + instructions: 691018270 heap_increase: 0 stable_memory_increase: 34 scopes: {} btreemap_v2_insert_blob_8_128: total: - instructions: 462943499 + instructions: 524164752 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_u64_blob8: total: - instructions: 422655288 + instructions: 491247984 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: - instructions: 431505229 + instructions: 500866926 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_vec8: total: - instructions: 429929989 + instructions: 501307103 heap_increase: 0 stable_memory_increase: 21 scopes: {} btreemap_v2_insert_vec8_u64: total: - instructions: 581931268 + instructions: 614982299 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_1024_128: total: - instructions: 3319375377 + instructions: 2789610913 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: - instructions: 1095946163 + instructions: 1042177787 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: - instructions: 703380587 + instructions: 738414762 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: - instructions: 1506981804 + instructions: 1423894681 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_1024: total: - instructions: 1222339084 + instructions: 1243910406 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: - instructions: 761818423 + instructions: 782955660 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_16: total: - instructions: 663288909 + instructions: 690772545 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_256: total: - instructions: 890722862 + instructions: 906365509 heap_increase: 0 stable_memory_increase: 54 scopes: {} btreemap_v2_insert_vec_32_32: total: - instructions: 666181941 + instructions: 684749908 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_4: total: - instructions: 660361307 + instructions: 684856776 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_512: total: - instructions: 1009138885 + instructions: 1026119993 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: - instructions: 692141273 + instructions: 716558458 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_vec_32_8: total: - instructions: 660131454 + instructions: 684037572 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_4_128: total: - instructions: 608680659 + instructions: 648407960 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: - instructions: 2128089786 + instructions: 1901572280 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: - instructions: 880497251 + instructions: 873371621 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: - instructions: 666361818 + instructions: 707096235 heap_increase: 0 stable_memory_increase: 23 scopes: {} btreemap_v2_mem_manager_contains_blob512_u64: total: - instructions: 2717630382 + instructions: 1775949161 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_blob512: total: - instructions: 311110875 + instructions: 311272695 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_u64: total: - instructions: 316748263 + instructions: 317156841 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_vec512: total: - instructions: 395074621 + instructions: 400392398 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_vec512_u64: total: - instructions: 1752116437 + instructions: 1258425858 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_blob512_u64: total: - instructions: 2762707145 + instructions: 1863808659 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_blob512: total: - instructions: 327868758 + instructions: 329294891 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_u64: total: - instructions: 329780567 + instructions: 331652326 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_vec512: total: - instructions: 421942583 + instructions: 427935018 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_vec512_u64: total: - instructions: 1789680475 + instructions: 1303577687 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_blob512_u64: total: - instructions: 2959846184 + instructions: 2597565947 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_blob512: total: - instructions: 647064908 + instructions: 707049704 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_u64: total: - instructions: 560836562 + instructions: 621126909 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: - instructions: 900634331 + instructions: 960296871 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: - instructions: 2238024968 + instructions: 2031591198 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: - instructions: 3847539102 + instructions: 3736567051 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: - instructions: 947364196 + instructions: 1034958115 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: - instructions: 807344380 + instructions: 892052152 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: - instructions: 1285424872 + instructions: 1375819243 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: - instructions: 3312475662 + instructions: 3198591960 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: - instructions: 608312410 + instructions: 629253248 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: - instructions: 9398188467 + instructions: 6147001197 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: - instructions: 2007415368 + instructions: 1531908056 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: - instructions: 757418973 + instructions: 765283250 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: - instructions: 3093785202 + instructions: 2185233950 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: - instructions: 1132453514 + instructions: 1116736838 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: - instructions: 876371666 + instructions: 860692670 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: - instructions: 819915580 + instructions: 802464245 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: - instructions: 907503807 + instructions: 892952288 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: - instructions: 831628016 + instructions: 811824098 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: - instructions: 802090340 + instructions: 786045356 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: - instructions: 973265658 + instructions: 960837938 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: - instructions: 838693246 + instructions: 823444657 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: - instructions: 818463796 + instructions: 802974323 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: - instructions: 371985311 + instructions: 399711532 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: - instructions: 5172264952 + instructions: 3509572847 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: - instructions: 1328879808 + instructions: 1025420211 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: - instructions: 611407100 + instructions: 634095102 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: - instructions: 705251730 + instructions: 753793039 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: - instructions: 717356696 + instructions: 768155629 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_vec8: total: - instructions: 709593211 + instructions: 757240426 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec8_u64: total: - instructions: 782287090 + instructions: 732991720 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: - instructions: 5764081817 + instructions: 4085915603 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: - instructions: 1816421653 + instructions: 1538597561 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: - instructions: 1024586335 + instructions: 969028764 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: - instructions: 2529716684 + instructions: 2055957144 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: - instructions: 1812179448 + instructions: 1717441040 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: - instructions: 1205040545 + instructions: 1114978395 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: - instructions: 1039338017 + instructions: 961475566 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: - instructions: 1327068201 + instructions: 1243299725 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: - instructions: 1055530159 + instructions: 955175429 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: - instructions: 1038272566 + instructions: 948465621 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: - instructions: 1490585519 + instructions: 1398936327 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: - instructions: 1089790483 + instructions: 1002725828 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: - instructions: 1050176827 + instructions: 959526555 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: - instructions: 537481485 + instructions: 519693694 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: - instructions: 3600978903 + instructions: 2758195778 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: - instructions: 1402296775 + instructions: 1262234043 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: - instructions: 845611404 + instructions: 808949551 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: - instructions: 592384197 + instructions: 605594719 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: - instructions: 9219664993 + instructions: 5830793696 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: - instructions: 1958516704 + instructions: 1465499866 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: - instructions: 738623017 + instructions: 738880823 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: - instructions: 3020531374 + instructions: 2079294367 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: - instructions: 1112565105 + instructions: 1085669333 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: - instructions: 854347996 + instructions: 830643675 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: - instructions: 798819040 + instructions: 769688933 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: - instructions: 886655818 + instructions: 861919416 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: - instructions: 810795267 + instructions: 780760100 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: - instructions: 787773960 + instructions: 760677261 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: - instructions: 955218753 + instructions: 933506500 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: - instructions: 820640883 + instructions: 795410677 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: - instructions: 797866799 + instructions: 771816802 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: - instructions: 363658412 + instructions: 386661070 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: - instructions: 5053410207 + instructions: 3345362741 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: - instructions: 1307018060 + instructions: 990351700 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: - instructions: 611183036 + instructions: 624461847 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: - instructions: 692890659 + instructions: 729066416 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: - instructions: 704605693 + instructions: 743800192 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_vec8: total: - instructions: 695997588 + instructions: 731910124 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec8_u64: total: - instructions: 763627664 + instructions: 708957905 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: - instructions: 6011671477 + instructions: 4313316700 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: - instructions: 1830309719 + instructions: 1552648335 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: - instructions: 1012789371 + instructions: 947358933 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: - instructions: 2583020373 + instructions: 2129557691 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: - instructions: 1807002225 + instructions: 1698443491 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: - instructions: 1204248068 + instructions: 1096848946 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: - instructions: 1028212700 + instructions: 941209083 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: - instructions: 1324529488 + instructions: 1226663580 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: - instructions: 1043904024 + instructions: 936303418 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: - instructions: 1036623333 + instructions: 934258686 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: - instructions: 1490891594 + instructions: 1389566809 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: - instructions: 1084573805 + instructions: 983167413 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: - instructions: 1038381761 + instructions: 937711654 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: - instructions: 528623870 + instructions: 504246189 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: - instructions: 3723931830 + instructions: 2873424953 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: - instructions: 1415805191 + instructions: 1255974553 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: - instructions: 853248522 + instructions: 801484501 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_1k_0b: total: - instructions: 16871 + instructions: 20115 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_1k_10kib: total: - instructions: 2440306 + instructions: 2986687 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_20_10mib: total: - instructions: 20572482 + instructions: 20584404 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_1k_0b: total: - instructions: 17405 + instructions: 20531 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_1k_10kib: total: - instructions: 57254917 + instructions: 57677193 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_20_10mib: total: - instructions: 1105826146 + instructions: 1105836590 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_1k_0b: total: - instructions: 17419 + instructions: 20545 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_1k_10kib: total: - instructions: 57266913 + instructions: 57689189 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_20_10mib: total: - instructions: 1105826382 + instructions: 1105836826 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_10mib_values: total: - instructions: 5561183230 + instructions: 5561272860 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: - instructions: 587170055 + instructions: 667900563 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: - instructions: 6474121980 + instructions: 6063706104 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: - instructions: 1466116527 + instructions: 1457463878 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: - instructions: 680002778 + instructions: 757672413 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: - instructions: 2195216146 + instructions: 2098091924 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: - instructions: 965884147 + instructions: 1036297823 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: - instructions: 731104521 + instructions: 801420541 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: - instructions: 687174807 + instructions: 755774413 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: - instructions: 765993262 + instructions: 837217335 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: - instructions: 695978850 + instructions: 765911420 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: - instructions: 679309894 + instructions: 750822623 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: - instructions: 837922202 + instructions: 911302025 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: - instructions: 720007632 + instructions: 793243985 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: - instructions: 679954212 + instructions: 749626337 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: - instructions: 455500790 + instructions: 522538214 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: - instructions: 3600501128 + instructions: 3448674395 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: - instructions: 1020115077 + instructions: 947748278 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: - instructions: 607878082 + instructions: 685714058 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: - instructions: 597538858 + instructions: 689441571 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: - instructions: 619109964 + instructions: 712995636 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_vec8: total: - instructions: 603458045 + instructions: 695853424 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec8_u64: total: - instructions: 750426147 + instructions: 804496668 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_1024_128: total: - instructions: 5022631520 + instructions: 4560037620 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: - instructions: 1452066520 + instructions: 1473629560 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: - instructions: 907746224 + instructions: 971674171 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: - instructions: 2314986697 + instructions: 2293167894 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: - instructions: 1674012367 + instructions: 1732355221 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: - instructions: 1010787616 + instructions: 1069927739 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_16: total: - instructions: 834640728 + instructions: 890477096 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_256: total: - instructions: 1229226325 + instructions: 1280544115 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_32: total: - instructions: 841144006 + instructions: 897812266 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_4: total: - instructions: 839617721 + instructions: 896826883 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_512: total: - instructions: 1392996478 + instructions: 1443936645 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: - instructions: 923651396 + instructions: 979473079 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_8: total: - instructions: 833306650 + instructions: 890819873 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_4_128: total: - instructions: 649657252 + instructions: 687282319 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: - instructions: 3266656938 + instructions: 3130403453 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: - instructions: 1178765367 + instructions: 1192475703 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: - instructions: 820045093 + instructions: 877067292 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_1k_0b: total: - instructions: 1493458 + instructions: 1981104 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_1k_10kib: total: - instructions: 57069957 + instructions: 57549224 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_20_10mib: total: - instructions: 1103719699 + instructions: 1103729363 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_rev_1k_0b: total: - instructions: 1495597 + instructions: 1981815 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_rev_1k_10kib: total: - instructions: 57047594 + instructions: 57530291 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_rev_20_10mib: total: - instructions: 1103719281 + instructions: 1103728938 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_1k_0b: total: - instructions: 946083 + instructions: 1551166 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_1k_10kib: total: - instructions: 2359607 + instructions: 2958502 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_20_10mib: total: - instructions: 18465439 + instructions: 18477478 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_rev_1k_0b: total: - instructions: 963320 + instructions: 1552873 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_rev_1k_10kib: total: - instructions: 2355505 + instructions: 2941017 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_rev_20_10mib: total: - instructions: 18465774 + instructions: 18477506 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_1k_0b: total: - instructions: 1490856 + instructions: 1941502 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_1k_10kib: total: - instructions: 57067355 + instructions: 57509622 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_20_10mib: total: - instructions: 1103719649 + instructions: 1103728573 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_rev_1k_0b: total: - instructions: 1492995 + instructions: 1942213 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_rev_1k_10kib: total: - instructions: 57044992 + instructions: 57490689 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_rev_20_10mib: total: - instructions: 1103719231 + instructions: 1103728148 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 4e84ccef..a74fe407 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -505,7 +505,7 @@ where let mut root = self.load_node(self.root_addr); // Check if the key already exists in the root. - if let Ok(idx) = root.search(&key) { + if let Ok(idx) = root.search(&key, self.memory()) { // The key exists. Overwrite it and return the previous value. let (_, previous_value) = root.swap_entry(idx, (key, value), self.memory()); self.save_node(&mut root); @@ -548,7 +548,7 @@ where assert!(!node.is_full()); // Look for the key in the node. - match node.search(&key) { + match node.search(&key, self.memory()) { Ok(idx) => { // The key is already in the node. // Overwrite it and return the previous value. @@ -581,7 +581,7 @@ where if child.is_full() { // Check if the key already exists in the child. - if let Ok(idx) = child.search(&key) { + if let Ok(idx) = child.search(&key, self.memory()) { // The key exists. Overwrite it and return the previous value. let (_, previous_value) = child.swap_entry(idx, (key, value), self.memory()); @@ -594,7 +594,7 @@ where // The children have now changed. Search again for // the child where we need to store the entry in. - let idx = node.search(&key).unwrap_or_else(|idx| idx); + let idx = node.search(&key, self.memory()).unwrap_or_else(|idx| idx); child = self.load_node(node.child(idx)); } @@ -608,7 +608,7 @@ where } } - /// Takes as input a nonfull internal `node` and index to its full child, then + /// Takes as input a non-full internal `node` and index to its full child, then /// splits this child into two, adding an additional child to `node`. /// /// Example: @@ -674,7 +674,7 @@ where { let node = self.load_node(node_addr); // Look for the key in the current node. - match node.search(key) { + match node.search(key, self.memory()) { Ok(idx) => Some(f(node, idx)), // Key found: apply `f`. Err(idx) => match node.node_type() { NodeType::Leaf => None, // At a leaf: key not present. @@ -791,7 +791,7 @@ where match node.node_type() { NodeType::Leaf => { - match node.search(key) { + match node.search(key, self.memory()) { Ok(idx) => { // Case 1: The node is a leaf node and the key exists in it. // This is the simplest case. The key is removed from the leaf. @@ -818,7 +818,7 @@ where } } NodeType::Internal => { - match node.search(key) { + match node.search(key, self.memory()) { Ok(idx) => { // Case 2: The node is an internal node and the key exists in it. @@ -1622,7 +1622,7 @@ mod test { assert!(right_child.is_full()); let median_index = right_child.entries_len() / 2; let median_key = key(12); - assert_eq!(right_child.key(median_index), &median_key); + assert_eq!(right_child.key(median_index, btree.memory()), &median_key); // Overwrite the value of the median key. assert_eq!(btree.insert(median_key.clone(), value(123)), Some(value(0))); @@ -3271,7 +3271,7 @@ mod test { // [0, 1, 2, 3, 4, 5] [7, 8, 9, 10, 11] let root = btree.load_node(btree.root_addr); assert_eq!(root.node_type(), NodeType::Internal); - assert_eq!(root.keys(), vec![vec![6; 10_000]]); + assert_eq!(root.keys(btree.memory()), vec![vec![6; 10_000]]); assert_eq!(root.children_len(), 2); // Remove the element in the root. @@ -3283,7 +3283,7 @@ mod test { // [0, 1, 2, 3, 4] [7, 8, 9, 10, 11] let root = btree.load_node(btree.root_addr); assert_eq!(root.node_type(), NodeType::Internal); - assert_eq!(root.keys(), vec![vec![5; 10_000]]); + assert_eq!(root.keys(btree.memory()), vec![vec![5; 10_000]]); assert_eq!(root.children_len(), 2); // Remove the element in the root. This triggers the case where the root @@ -3295,7 +3295,7 @@ mod test { let root = btree.load_node(btree.root_addr); assert_eq!(root.node_type(), NodeType::Leaf); assert_eq!( - root.keys(), + root.keys(btree.memory()), vec![ vec![0; 10_000], vec![1; 10_000], diff --git a/src/btreemap/iter.rs b/src/btreemap/iter.rs index 82869508..1e653e16 100644 --- a/src/btreemap/iter.rs +++ b/src/btreemap/iter.rs @@ -94,7 +94,7 @@ where Bound::Included(key) | Bound::Excluded(key) => { let mut node = self.map.load_node(self.map.root_addr); loop { - match node.search(key) { + match node.search(key, self.map.memory()) { Ok(idx) => { if let Bound::Included(_) = self.range.start_bound() { // We found the key exactly matching the left bound. @@ -115,7 +115,7 @@ where }; if idx + 1 < node.entries_len() - && self.range.contains(node.key(idx + 1)) + && self.range.contains(node.key(idx + 1, self.map.memory())) { self.forward_cursors.push(Cursor::Node { node, @@ -152,7 +152,9 @@ where NodeType::Leaf => None, }; - if idx < node.entries_len() && self.range.contains(node.key(idx)) { + if idx < node.entries_len() + && self.range.contains(node.key(idx, self.map.memory())) + { self.forward_cursors.push(Cursor::Node { node, next: Index::Entry(idx), @@ -188,7 +190,7 @@ where Bound::Included(key) | Bound::Excluded(key) => { let mut node = self.map.load_node(self.map.root_addr); loop { - match node.search(key) { + match node.search(key, self.map.memory()) { Ok(idx) => { if let Bound::Included(_) = self.range.end_bound() { // We found the key exactly matching the right bound. @@ -208,7 +210,9 @@ where NodeType::Leaf => None, }; - if idx > 0 && self.range.contains(node.key(idx - 1)) { + if idx > 0 + && self.range.contains(node.key(idx - 1, self.map.memory())) + { self.backward_cursors.push(Cursor::Node { node, next: Index::Entry(idx - 1), @@ -243,7 +247,8 @@ where NodeType::Leaf => None, }; - if idx > 0 && self.range.contains(node.key(idx - 1)) { + if idx > 0 && self.range.contains(node.key(idx - 1, self.map.memory())) + { self.backward_cursors.push(Cursor::Node { node, next: Index::Entry(idx - 1), @@ -320,7 +325,7 @@ where next: Index::Entry(entry_idx), } => { // If the key does not belong to the range, iteration stops. - if !self.range.contains(node.key(entry_idx)) { + if !self.range.contains(node.key(entry_idx, self.map.memory())) { // Clear all cursors to avoid needless work in subsequent calls. self.forward_cursors = vec![]; self.backward_cursors = vec![]; @@ -328,7 +333,7 @@ where } let res = map(&node, entry_idx); - self.range.0 = Bound::Excluded(node.key(entry_idx).clone()); + self.range.0 = Bound::Excluded(node.key(entry_idx, self.map.memory()).clone()); let next = match node.node_type() { // If this is an internal node, add the next child to the cursors. @@ -403,7 +408,7 @@ where next: Index::Entry(entry_idx), } => { // If the key does not belong to the range, iteration stops. - if !self.range.contains(node.key(entry_idx)) { + if !self.range.contains(node.key(entry_idx, self.map.memory())) { // Clear all cursors to avoid needless work in subsequent calls. self.forward_cursors = vec![]; self.backward_cursors = vec![]; @@ -411,7 +416,7 @@ where } let res = map(&node, entry_idx); - self.range.1 = Bound::Excluded(node.key(entry_idx).clone()); + self.range.1 = Bound::Excluded(node.key(entry_idx, self.map.memory()).clone()); if let Some(next) = match node.node_type() { // If this is an internal node, add the previous child to the cursors. @@ -497,7 +502,7 @@ where fn next(&mut self) -> Option { self.0 - .next_map(|node, entry_idx| node.key(entry_idx).clone()) + .next_map(|node, entry_idx| node.key(entry_idx, self.0.map.memory()).clone()) } fn count(mut self) -> usize @@ -516,7 +521,7 @@ where { fn next_back(&mut self) -> Option { self.0 - .next_back_map(|node, entry_idx| node.key(entry_idx).clone()) + .next_back_map(|node, entry_idx| node.key(entry_idx, self.0.map.memory()).clone()) } } diff --git a/src/btreemap/node.rs b/src/btreemap/node.rs index 50af80e0..4577dec3 100644 --- a/src/btreemap/node.rs +++ b/src/btreemap/node.rs @@ -39,6 +39,8 @@ pub enum NodeType { pub type Entry = (K, Vec); pub type EntryRef<'a, K> = (&'a K, &'a [u8]); +type LazyEntry = (LazyKey, LazyValue); + /// A node of a B-Tree. /// /// There are two versions of a `Node`: @@ -52,7 +54,7 @@ pub struct Node { address: Address, // List of tuples consisting of a key and the encoded value. // INVARIANT: the list is sorted by key. - keys_and_encoded_values: Vec<(K, Value)>, + keys_and_encoded_values: Vec>, // For the key at position I, children[I] points to the left // child of this key and children[I + 1] points to the right child. children: Vec
, @@ -106,14 +108,13 @@ impl Node { pub fn get_max(&self, memory: &M) -> Entry { match self.node_type { NodeType::Leaf => { - let last_idx = self.keys_and_encoded_values.len() - 1; + let last_entry = self + .keys_and_encoded_values + .last() + .expect("A node can never be empty"); ( - self.keys_and_encoded_values - .last() - .expect("A node can never be empty") - .0 - .clone(), - self.value(last_idx, memory).to_vec(), + self.get_key(last_entry, memory).clone(), + self.get_value(last_entry, memory).to_vec(), ) } NodeType::Internal => { @@ -164,32 +165,92 @@ impl Node { ) -> Entry { let (old_key, old_value) = core::mem::replace( &mut self.keys_and_encoded_values[idx], - (key, Value::by_value(value)), + (LazyKey::by_value(key), LazyValue::by_value(value)), ); - (old_key, self.extract_value(old_value, memory)) + ( + self.extract_key(old_key, memory), + self.extract_value(old_value, memory), + ) } /// Returns a reference to the entry at the specified index. pub fn entry(&self, idx: usize, memory: &M) -> EntryRef { - ( - &self.keys_and_encoded_values[idx].0, - self.value(idx, memory), - ) + (self.key(idx, memory), self.value(idx, memory)) + } + + /// Returns a reference to the cached key and loads it from memory if needed. + #[inline] + fn get_key<'a, M: Memory>(&'a self, (k, _): &'a LazyEntry, memory: &M) -> &'a K { + k.get_or_load(|offset| self.load_key_from_memory(offset, memory)) + } + + /// Returns a reference to the cached value and loads it from memory if needed. + #[inline] + fn get_value<'a, M: Memory>(&'a self, (_, v): &'a LazyEntry, memory: &M) -> &'a [u8] { + v.get_or_load(|offset| self.load_value_from_memory(offset, memory)) + } + + /// Returns a reference to the key at the specified index. + pub fn key(&self, idx: usize, memory: &M) -> &K { + self.get_key(&self.keys_and_encoded_values[idx], memory) } /// Returns a reference to the encoded value at the specified index. pub fn value(&self, idx: usize, memory: &M) -> &[u8] { - // Load and cache the value from the underlying memory if needed. - self.keys_and_encoded_values[idx] - .1 - .get_or_load(|offset| self.load_value_from_memory(offset, memory)) + self.get_value(&self.keys_and_encoded_values[idx], memory) + } + + /// Extracts the contents of key (by loading it first if it's not loaded yet). + fn extract_key(&self, key: LazyKey, memory: &M) -> K { + key.take_or_load(|offset| self.load_key_from_memory(offset, memory)) } /// Extracts the contents of value (by loading it first if it's not loaded yet). - fn extract_value(&self, value: Value, memory: &M) -> Vec { + fn extract_value(&self, value: LazyValue, memory: &M) -> Vec { value.take_or_load(|offset| self.load_value_from_memory(offset, memory)) } + /// Loads a key from stable memory at the given offset of this node. + fn load_key_from_memory(&self, mut offset: Bytes, memory: &M) -> K { + let reader = NodeReader { + address: self.address, + overflows: &self.overflows, + page_size: self.page_size(), + memory, + }; + + // Retrieve the key's size. + let key_offset = Address::from(offset.get()); + let key_size = match self.version { + Version::V1(_) => { + // In V1, the key's size is always stored in memory. + offset += U32_SIZE; + read_u32(&reader, key_offset) + } + Version::V2(_) => { + // In V2, if the key is fixed-size, use the maximum bound; + // otherwise, read its size from memory. + if K::BOUND.is_fixed_size() { + K::BOUND.max_size() + } else { + offset += U32_SIZE; + read_u32(&reader, key_offset) + } + } + }; + + let mut bytes = vec![]; + read_to_vec( + &reader, + Address::from((offset).get()), + &mut bytes, + key_size as usize, + ); + let key = K::from_bytes(Cow::Borrowed(&bytes)); + + key + } + /// Loads a value from stable memory at the given offset of this node. fn load_value_from_memory(&self, offset: Bytes, memory: &M) -> Vec { let reader = NodeReader { @@ -199,13 +260,13 @@ impl Node { memory, }; - let value_len = read_u32(&reader, Address::from(offset.get())) as usize; + let value_size = read_u32(&reader, Address::from(offset.get())) as usize; let mut bytes = vec![]; read_to_vec( &reader, Address::from((offset + U32_SIZE).get()), &mut bytes, - value_len, + value_size, ); bytes @@ -215,11 +276,6 @@ impl Node { self.version.page_size() } - /// Returns a reference to the key at the specified index. - pub fn key(&self, idx: usize) -> &K { - &self.keys_and_encoded_values[idx].0 - } - /// Returns the child's address at the given index. pub fn child(&self, idx: usize) -> Address { self.children[idx] @@ -251,28 +307,34 @@ impl Node { } /// Inserts a new entry at the specified index. - pub fn insert_entry(&mut self, idx: usize, (key, encoded_value): Entry) { + pub fn insert_entry(&mut self, idx: usize, (key, value): Entry) { self.keys_and_encoded_values - .insert(idx, (key, Value::by_value(encoded_value))); + .insert(idx, (LazyKey::by_value(key), LazyValue::by_value(value))); } /// Returns the entry at the specified index while consuming this node. pub fn into_entry(mut self, idx: usize, memory: &M) -> Entry { let keys_and_encoded_values = core::mem::take(&mut self.keys_and_encoded_values); let (key, value) = keys_and_encoded_values.into_iter().nth(idx).unwrap(); - (key, self.extract_value(value, memory)) + ( + self.extract_key(key, memory), + self.extract_value(value, memory), + ) } /// Removes the entry at the specified index. pub fn remove_entry(&mut self, idx: usize, memory: &M) -> Entry { let (key, value) = self.keys_and_encoded_values.remove(idx); - (key, self.extract_value(value, memory)) + ( + self.extract_key(key, memory), + self.extract_value(value, memory), + ) } /// Adds a new entry at the back of the node. - pub fn push_entry(&mut self, (key, encoded_value): Entry) { + pub fn push_entry(&mut self, (key, value): Entry) { self.keys_and_encoded_values - .push((key, Value::by_value(encoded_value))); + .push((LazyKey::by_value(key), LazyValue::by_value(value))); } /// Removes an entry from the back of the node. @@ -282,12 +344,15 @@ impl Node { return None; } - let (key, last_value) = self + let (key, value) = self .keys_and_encoded_values .pop() .expect("node must not be empty"); - Some((key, self.extract_value(last_value, memory))) + Some(( + self.extract_key(key, memory), + self.extract_value(value, memory), + )) } /// Merges the entries and children of the `source` node into self, along with the median entry. @@ -307,19 +372,19 @@ impl Node { median: Entry, allocator: &mut Allocator, ) { - // Load all the values from the source node first, as they will be moved out. + // Load all the entries from the source node first, as they will be moved out. for i in 0..source.entries_len() { - source.value(i, allocator.memory()); + let _e = source.entry(i, allocator.memory()); } - if source.key(0) > self.key(0) { + if source.key(0, allocator.memory()) > self.key(0, allocator.memory()) { // The source node has keys that are greater than self. // Append the source node into self. - Self::append(self, &mut source, median); + Self::append(self, &mut source, median, allocator.memory()); } else { // self has keys that are greater than the source node. // Append self into the source node (which more efficient). - Self::append(&mut source, self, median); + Self::append(&mut source, self, median, allocator.memory()); // Move the entries and children into self. self.keys_and_encoded_values = core::mem::take(&mut source.keys_and_encoded_values); @@ -340,14 +405,14 @@ impl Node { /// /// POSTCONDITION: /// * `b` is empty. - fn append(a: &mut Node, b: &mut Node, median: Entry) { + fn append(a: &mut Node, b: &mut Node, median: Entry, memory: &M) { // Assert preconditions. let a_len = a.entries_len(); assert_eq!(a.node_type(), b.node_type()); assert!(b.entries_len() > 0); assert!(a_len > 0); - assert!(a.key(a_len - 1) < &median.0); - assert!(&median.0 < b.key(0)); + assert!(a.key(a_len - 1, memory) < &median.0); + assert!(&median.0 < b.key(0, memory)); a.push_entry(median); @@ -364,18 +429,15 @@ impl Node { #[cfg(test)] pub fn entries(&self, memory: &M) -> Vec> { - self.keys_and_encoded_values - .iter() - .enumerate() - .map(|(idx, (key, _))| (key.clone(), self.value(idx, memory).to_vec())) + (0..self.keys_and_encoded_values.len()) + .map(|i| (self.key(i, memory).clone(), self.value(i, memory).to_vec())) .collect() } #[cfg(test)] - pub fn keys(&self) -> Vec { - self.keys_and_encoded_values - .iter() - .map(|(key, _)| key.clone()) + pub fn keys(&self, memory: &M) -> Vec { + (0..self.keys_and_encoded_values.len()) + .map(|i| self.key(i, memory).clone()) .collect() } @@ -395,9 +457,9 @@ impl Node { /// of the matching key. If the value is not found then `Result::Err` is /// returned, containing the index where a matching key could be inserted /// while maintaining sorted order. - pub fn search(&self, key: &K) -> Result { + pub fn search(&self, key: &K, memory: &M) -> Result { self.keys_and_encoded_values - .binary_search_by_key(&key, |entry| &entry.0) + .binary_search_by_key(&key, |entry| self.get_key(entry, memory)) } /// Returns the maximum size a node can be if it has bounded keys and values. @@ -422,9 +484,9 @@ impl Node { pub fn split(&mut self, sibling: &mut Node, memory: &M) -> Entry { debug_assert!(self.is_full()); - // Load the values that will be moved out of the node and into the new sibling. + // Load the entries that will be moved out of the node and into the new sibling. for idx in B..self.entries_len() { - self.value(idx, memory); + let _e = self.entry(idx, memory); } // Move the entries and children above the median into the new sibling. @@ -463,53 +525,134 @@ impl NodeHeader { } } -/// The value in a K/V pair. +struct LazyKey(LazyObject); + +impl LazyKey { + /// Create a lazy key with a memory offset. + #[inline] + pub fn by_ref(offset: Bytes) -> Self { + Self(LazyObject::by_ref(offset)) + } + + /// Create a lazy key from a key. + #[inline] + pub fn by_value(key: K) -> Self { + Self(LazyObject::by_value(key)) + } + + /// Returns a reference to the key, loading it if necessary. + #[inline] + pub fn get_or_load(&self, load: impl FnOnce(Bytes) -> K) -> &K { + self.0.get_or_load(load) + } + + /// Consumes self and returns the key, loading it if necessary. + #[inline] + pub fn take_or_load(self, load: impl FnOnce(Bytes) -> K) -> K { + self.0.take_or_load(load) + } +} + +impl std::fmt::Debug for LazyKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match &self.0 { + LazyObject::ByVal(ref key) => { + let bytes = key.to_bytes_checked(); + f.debug_tuple("LazyKey") + .field(&format_args!("LazyKey::ByVal({:?})", bytes)) + .finish() + } + LazyObject::ByRef { offset, loaded } => match loaded.get() { + Some(key) => { + let bytes = key.to_bytes_checked(); + f.debug_tuple("LazyKey") + .field(&format_args!("LazyKey::ByRef(loaded:{:?})", bytes)) + .finish() + } + None => f + .debug_tuple("LazyKey") + .field(&format_args!("LazyKey::ByRef(offset: {:?})", offset)) + .finish(), + }, + } + } +} + +type Blob = Vec; + #[derive(Debug)] -enum Value { - /// The value's encoded bytes. - ByVal(Vec), +struct LazyValue(LazyObject); +impl LazyValue { + /// Create a lazy value with a memory offset. + #[inline] + pub fn by_ref(offset: Bytes) -> Self { + Self(LazyObject::by_ref(offset)) + } + + /// Create a lazy value from a value. + #[inline] + pub fn by_value(value: Blob) -> Self { + Self(LazyObject::by_value(value)) + } + + /// Returns a reference to the key, loading it if necessary. + #[inline] + pub fn get_or_load(&self, load: impl FnOnce(Bytes) -> Blob) -> &Blob { + self.0.get_or_load(load) + } + + /// Consumes self and returns the key, loading it if necessary. + #[inline] + pub fn take_or_load(self, load: impl FnOnce(Bytes) -> Blob) -> Blob { + self.0.take_or_load(load) + } +} + +/// A lazy-loaded object. +#[derive(Debug)] +enum LazyObject { + /// Object stored by value. + ByVal(T), + + /// Object stored by reference, loaded on demand. ByRef { - /// The value's offset in the node. + /// Memory offset of the object. offset: Bytes, - /// The lazily loaded encoded bytes. - loaded_value: OnceCell>, + /// Cache for the lazily loaded object. + loaded: OnceCell, }, } -impl Value { +impl LazyObject { + /// Create a lazy object with a memory offset. pub fn by_ref(offset: Bytes) -> Self { Self::ByRef { offset, - loaded_value: Default::default(), + loaded: Default::default(), } } - pub fn by_value(value: Vec) -> Self { + /// Create a lazy object from a value. + pub fn by_value(value: T) -> Self { Self::ByVal(value) } - /// Returns a reference to the value if the value has been loaded or runs the given function to - /// load the value. - pub fn get_or_load(&self, load: impl FnOnce(Bytes) -> Vec) -> &[u8] { + /// Get a reference to the object, loading it if necessary. + pub fn get_or_load(&self, load: impl FnOnce(Bytes) -> T) -> &T { match self { - Value::ByVal(v) => &v[..], - Value::ByRef { - offset, - loaded_value: value, - } => value.get_or_init(|| load(*offset)), + LazyObject::ByVal(v) => v, + LazyObject::ByRef { offset, loaded } => loaded.get_or_init(|| load(*offset)), } } - /// Extracts the value while consuming self if the value has been loaded or runs the given - /// function to load the value. - pub fn take_or_load(self, load: impl FnOnce(Bytes) -> Vec) -> Vec { + /// Consume self and return the object, loading it if necessary. + pub fn take_or_load(self, load: impl FnOnce(Bytes) -> T) -> T { match self { - Value::ByVal(v) => v, - Value::ByRef { - offset, - loaded_value: value, - } => value.into_inner().unwrap_or_else(|| load(offset)), + LazyObject::ByVal(v) => v, + LazyObject::ByRef { offset, loaded } => { + loaded.into_inner().unwrap_or_else(|| load(offset)) + } } } } diff --git a/src/btreemap/node/v1.rs b/src/btreemap/node/v1.rs index 2b8eac0d..63e13327 100644 --- a/src/btreemap/node/v1.rs +++ b/src/btreemap/node/v1.rs @@ -69,20 +69,18 @@ impl Node { // Load the entries. let mut keys_encoded_values = Vec::with_capacity(header.num_entries as usize); let mut offset = NodeHeader::size(); - let mut buf = vec![]; for _ in 0..header.num_entries { - // Read the key's size. - let key_size = read_u32(memory, address + offset); + let key_offset = offset; offset += U32_SIZE; - - // Read the key. - read_to_vec(memory, address + offset, &mut buf, key_size as usize); + let key = LazyKey::by_ref(key_offset); offset += Bytes::from(max_key_size); - let key = K::from_bytes(Cow::Borrowed(&buf)); - // Values are loaded lazily. Store a reference and skip loading it. - keys_encoded_values.push((key, Value::by_ref(offset))); - offset += U32_SIZE + Bytes::from(max_value_size); + let value_offset = offset; + offset += U32_SIZE; + let value = LazyValue::by_ref(value_offset); + offset += Bytes::from(max_value_size); + + keys_encoded_values.push((key, value)); } // Load children if this is an internal node. @@ -136,7 +134,7 @@ impl Node { assert!(self .keys_and_encoded_values .windows(2) - .all(|e| e[0].0 < e[1].0)); + .all(|arr| self.get_key(&arr[0], memory) < self.get_key(&arr[1], memory))); let (max_key_size, max_value_size) = match self.version { Version::V1(DerivedPageSize { @@ -160,16 +158,16 @@ impl Node { let mut offset = NodeHeader::size(); - // Load all the values. This is necessary so that we don't overwrite referenced - // values when writing the entries to the node. + // Load all the entries. This is necessary so that we don't overwrite referenced + // entries when writing the entries to the node. for i in 0..self.keys_and_encoded_values.len() { - self.value(i, memory); + self.entry(i, memory); } // Write the entries. - for (idx, (key, _)) in self.keys_and_encoded_values.iter().enumerate() { + for i in 0..self.keys_and_encoded_values.len() { // Write the size of the key. - let key_bytes = key.to_bytes_checked(); + let key_bytes = self.key(i, memory).to_bytes_checked(); write_u32(memory, self.address + offset, key_bytes.len() as u32); offset += U32_SIZE; @@ -178,7 +176,7 @@ impl Node { offset += Bytes::from(max_key_size); // Write the size of the value. - let value = self.value(idx, memory); + let value = self.value(i, memory); write_u32(memory, self.address + offset, value.len() as u32); offset += U32_SIZE; diff --git a/src/btreemap/node/v2.rs b/src/btreemap/node/v2.rs index b24ce05f..1b448cd3 100644 --- a/src/btreemap/node/v2.rs +++ b/src/btreemap/node/v2.rs @@ -151,32 +151,34 @@ impl Node { // Load the keys. let mut keys_encoded_values = Vec::with_capacity(num_entries); - let mut buf = vec![]; for _ in 0..num_entries { - // Load the key's size. + let key_offset = Bytes::from(offset.get()); + + // Advance offset by the key_size type size if applicable. let key_size = if K::BOUND.is_fixed_size() { // Key is fixed in size. The size of the key is always its max size. K::BOUND.max_size() } else { // Key is not fixed in size. Read the size from memory. - let value = read_u32(&reader, offset); + let key_size = read_u32(&reader, offset); offset += U32_SIZE; - value + key_size }; + let key = LazyKey::by_ref(key_offset); - // Load the key. - read_to_vec(&reader, offset, &mut buf, key_size as usize); - let key = K::from_bytes(Cow::Borrowed(&buf)); + // Advance offset by the size of the key. offset += Bytes::from(key_size); - keys_encoded_values.push((key, Value::by_ref(Bytes::from(0usize)))); + + keys_encoded_values.push((key, LazyValue::by_ref(Bytes::from(0usize)))); } // Load the values for (_key, value) in keys_encoded_values.iter_mut() { - // Load the values lazily. - *value = Value::by_ref(Bytes::from(offset.get())); - let value_size = read_u32(&reader, offset) as usize; - offset += U32_SIZE + Bytes::from(value_size as u64); + let value_offset = Bytes::from(offset.get()); + let value_size = read_u32(&reader, offset); + offset += U32_SIZE; + *value = LazyValue::by_ref(value_offset); + offset += Bytes::from(value_size as u64); } Self { @@ -197,11 +199,11 @@ impl Node { let page_size = self.version.page_size().get(); assert!(page_size >= MINIMUM_PAGE_SIZE); - // Load all the values. This is necessary so that we don't overwrite referenced - // values when writing the entries to the node. - for i in 0..self.keys_and_encoded_values.len() { - self.value(i, allocator.memory()); - } + // Load all the entry. This is necessary so that we don't overwrite referenced + // entry when writing the entries to the node. + let entries: Vec<_> = (0..self.keys_and_encoded_values.len()) + .map(|i| self.entry(i, allocator.memory())) + .collect(); // Initialize a NodeWriter. The NodeWriter takes care of allocating/deallocating // overflow pages as needed. @@ -239,9 +241,8 @@ impl Node { } // Write the keys. - for (key, _) in self.keys_and_encoded_values.iter() { + for (key, _) in &entries { let key_bytes = key.to_bytes_checked(); - // Write the size of the key if it isn't fixed in size. if !K::BOUND.is_fixed_size() { writer.write_u32(offset, key_bytes.len() as u32); @@ -254,9 +255,8 @@ impl Node { } // Write the values. - for idx in 0..self.entries_len() { + for (_, value) in &entries { // Write the size of the value. - let value = self.value(idx, writer.memory()); writer.write_u32(offset, value.len() as u32); offset += U32_SIZE;