IntersectMBO / lsm-tree

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

Eliminate some allocations from ordinary index search #264

Open jeltsch opened 5 months ago

jeltsch commented 5 months ago

The search function of the ordinary index can probably get by with less allocations. We shall conduct a micro-benchmark in the style of the compact-index micro-benchmark and use its results to reduce the allocation count by turning specific patterns into bang patterns. See https://github.com/IntersectMBO/lsm-tree/pull/244#discussion_r1632935316 and follow-ups.

We shall extend the above-mentioned optimization to the binarySearchL function for immutable vectors, which is used by search, in case we haven’t ended up implementing that function by reusing binarySearchL from vector-algorithms.

jeltsch commented 2 months ago

We have ended up implementing the binarySearchL function for immutable vectors by reusing binarySearchL from vector-algorithms (see #256); so there is nothing to be done regarding that function.

jeltsch commented 2 months ago

Note that #393 introduces a variable overflowPageCount, which is local to the variable end and is used only in the first branch of end’s definition, so that its binding pattern should probably not be made strict, as it is not used in the second branch of end’s definition.

jeltsch commented 2 months ago

Note that #393 introduces a variable overflowPageCount, which is local to the variable end and is used only in the first branch of end’s definition, so that its binding pattern should probably not be made strict, as it is not used in the second branch of end’s definition.

During further changes within #393, things were arranged differently such that now the above-mentioned issue doesn’t occur anymore.

jeltsch commented 2 months ago

There were sensible strictness annotations introduced as part of #393. We should check whether a micro-benchmark is still needed or whether we can trust that the present implementation is fine.

jorisdral commented 2 months ago

A micro-benchmark would still be useful IMO, and it does not have to be a particularly elaborate one