IntersectMBO / lsm-tree

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

Change the serialisation of `UTxOKey` #308

Closed jorisdral closed 1 month ago

jorisdral commented 1 month ago

Comparing the Serialise benchmark before and after #308

Benchmark                                                                before    after
Bench.Database.LSMTree.Internal.Serialise/UTxOKey/serialiseKey           0.593e-8  2.870e-8 +383.88%
Bench.Database.LSMTree.Internal.Serialise/UTxOKey/serialiseKeyRoundtrip  0.734e-8  4.863e-8 +562.07%
Geometric mean                                                           0.660e-8  3.736e-8 +466.00%

before.log before.csv after.log after.csv

Comparing the first commit of #306 and after #308

Benchmark                                                                                  before    after
Bench.Database.LSMTree.Internal.IndexCompact/construction/construction-1k-100              0.404e-4  0.255e-4 -36.90%
Bench.Database.LSMTree.Internal.IndexCompact/construction/unsafeWriteRange-10k             0.585e-6  0.593e-6  +1.42%
Bench.Database.LSMTree.Internal.IndexCompact/construction/unsafeWriteRange-1k              0.947e-7  0.984e-7  +3.82%
Bench.Database.LSMTree.Internal.IndexCompact/non-uniformity/construct appsWithNearDups     1.959e-4  0.248e-4 -87.33%
Bench.Database.LSMTree.Internal.IndexCompact/non-uniformity/construct appsWithoutNearDups  0.393e-4  0.247e-4 -37.09%
Bench.Database.LSMTree.Internal.IndexCompact/non-uniformity/search appsWithNearDups        0.944e-3  0.021e-3 -97.76%
Bench.Database.LSMTree.Internal.IndexCompact/non-uniformity/search appsWithoutNearDups     2.884e-5  2.308e-5 -19.97%
Bench.Database.LSMTree.Internal.IndexCompact/searches-10-1k                                0.411e-4  0.429e-4  +4.28%
Geometric mean                                                                             1.930e-5  0.813e-5 -57.89%

before.log before.csv after.log after.csv

jorisdral commented 1 month ago

Maybe you can still avoid the allocations before merging, but generally looks good to me.

I might try optimising the serialise function before I merge this one, or else create a TODO. BTW, I'd like to merge #306 and #307 first before we merge #308