IntersectMBO / lsm-tree

A Haskell library for on-disk tables based on LSM-trees
Apache License 2.0
24 stars 7 forks source link

Optimise `unsafeWriteRange` #294

Closed jorisdral closed 1 month ago

jorisdral commented 1 month ago
Benchmark                                                                                                     before    after
Bench.Database.LSMTree.Internal.IndexCompact/construction/construction with 0-bit  rfprec and chunk size 100  0.394e-4  0.396e-4  +0.54%
Bench.Database.LSMTree.Internal.IndexCompact/construction/construction with 16-bit rfprec and chunk size 100  2.351e-4  1.047e-4 -55.49%
Bench.Database.LSMTree.Internal.IndexCompact/searches/searches with 0-bit  rfprec                             0.413e-4  0.411e-4  -0.51%
Bench.Database.LSMTree.Internal.IndexCompact/searches/searches with 16-bit rfprec                             0.985e-5  0.947e-5  -3.84%
Geometric mean                                                                                                0.441e-4  0.067e-4 -84.75%

This also saves around 10% of allocations in the construction benchmarks. The unsafeWriteRange function has a constant number of allocated bytes, which it means it nicely unboxes everything