Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
76: feat: implement optimised insert_range r=Kerollmops a=domodwyer Implements an optimised `insert_range()` function for efficiently adding consecutive elements to the set. Previously the easiest way to do this was with `extends()` or calling `insert()` in a loop. To insert 100,000 elements this took about `1,000us` - with the `insert_range()` this completes in `~2us`. <details><summary> Bechmarks </summary> `insert_range()` vs. `insert()` in a loop inserting 0..N: ```text add_range/roaring/10 time: [191.80 ns 194.15 ns 197.16 ns] thrpt: [50.720 Melem/s 51.506 Melem/s 52.137 Melem/s] change: time: [-58.031% -57.320% -56.475%] (p = 0.00 < 0.05) thrpt: [+129.75% +134.30% +138.27%] Performance has improved. add_range/pre_populated_roaring/10 time: [177.77 ns 180.03 ns 182.21 ns] thrpt: [54.881 Melem/s 55.547 Melem/s 56.252 Melem/s] change: time: [-36.465% -34.812% -33.125%] (p = 0.00 < 0.05) thrpt: [+49.532% +53.404% +57.393%] Performance has improved. add_range/roaring/100 time: [342.94 ns 346.12 ns 351.19 ns] thrpt: [284.75 Melem/s 288.92 Melem/s 291.60 Melem/s] change: time: [-85.032% -84.862% -84.654%] (p = 0.00 < 0.05) thrpt: [+551.63% +560.58% +568.10%] Performance has improved. add_range/pre_populated_roaring/100 time: [366.68 ns 371.57 ns 376.29 ns] thrpt: [265.76 Melem/s 269.13 Melem/s 272.72 Melem/s] change: time: [-83.662% -83.417% -83.156%] (p = 0.00 < 0.05) thrpt: [+493.70% +503.04% +512.08%] Performance has improved. add_range/roaring/1000 time: [1.6535 us 1.6579 us 1.6630 us] thrpt: [601.33 Melem/s 603.16 Melem/s 604.78 Melem/s] change: time: [-91.569% -91.513% -91.457%] (p = 0.00 < 0.05) thrpt: [+1070.6% +1078.3% +1086.1%] Performance has improved. add_range/pre_populated_roaring/1000 time: [1.7225 us 1.7491 us 1.7824 us] thrpt: [561.03 Melem/s 571.72 Melem/s 580.56 Melem/s] change: time: [-94.873% -94.807% -94.737%] (p = 0.00 < 0.05) thrpt: [+1800.0% +1825.8% +1850.5%] Performance has improved. add_range/roaring/5000 time: [317.68 ns 319.43 ns 321.60 ns] thrpt: [15.547 Gelem/s 15.653 Gelem/s 15.739 Gelem/s] change: time: [-99.669% -99.665% -99.661%] (p = 0.00 < 0.05) thrpt: [+29373% +29744% +30135%] Performance has improved. add_range/pre_populated_roaring/5000 time: [844.07 ns 907.00 ns 966.49 ns] thrpt: [5.1733 Gelem/s 5.5127 Gelem/s 5.9237 Gelem/s] change: time: [-98.691% -98.541% -98.365%] (p = 0.00 < 0.05) thrpt: [+6015.9% +6753.8% +7541.4%] Performance has improved. add_range/roaring/10000 time: [373.12 ns 373.91 ns 374.77 ns] thrpt: [26.683 Gelem/s 26.745 Gelem/s 26.801 Gelem/s] change: time: [-99.736% -99.734% -99.732%] (p = 0.00 < 0.05) thrpt: [+37214% +37481% +37710%] Performance has improved. add_range/pre_populated_roaring/10000 time: [936.65 ns 1.0032 us 1.0666 us] thrpt: [9.3760 Gelem/s 9.9681 Gelem/s 10.676 Gelem/s] change: time: [-99.237% -99.132% -99.035%] (p = 0.00 < 0.05) thrpt: [+10258% +11415% +13008%] Performance has improved. add_range/roaring/100000 time: [1.4464 us 1.4534 us 1.4613 us] thrpt: [68.431 Gelem/s 68.806 Gelem/s 69.135 Gelem/s] change: time: [-99.866% -99.864% -99.861%] (p = 0.00 < 0.05) thrpt: [+71984% +73250% +74639%] Performance has improved. add_range/pre_populated_roaring/100000 time: [1.8819 us 1.9888 us 2.1003 us] thrpt: [47.612 Gelem/s 50.283 Gelem/s 53.137 Gelem/s] change: time: [-99.864% -99.849% -99.831%] (p = 0.00 < 0.05) thrpt: [+59136% +66238% +73485%] Performance has improved. ``` </details> The API exposed copies the `remove_range()` function, accepting a `Range<u64>` (a half-open range) in order to allow including `u32::MAX`. Co-authored-by: Dom <[email protected]>
- Loading branch information