Skip to content

Commit 6f02f40

Browse files
committed
feat(lsm-tree-bench-lookups): add salt
1 parent b581ccd commit 6f02f40

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

bench/macro/lsm-tree-bench-lookups.hs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import Database.LSMTree.Internal.Entry (Entry (Insert),
2828
import Database.LSMTree.Internal.Index (Index)
2929
import qualified Database.LSMTree.Internal.Index as Index (IndexType (Compact))
3030
import Database.LSMTree.Internal.Lookup
31-
import Database.LSMTree.Internal.Paths (RunFsPaths (RunFsPaths))
31+
import Database.LSMTree.Internal.Paths (RunFsPaths (RunFsPaths),
32+
SessionSalt (SessionSalt))
3233
import Database.LSMTree.Internal.Run (Run)
3334
import qualified Database.LSMTree.Internal.Run as Run
3435
import Database.LSMTree.Internal.RunAcc (RunBloomFilterAlloc (..))
@@ -129,6 +130,9 @@ entryBitsWithOverhead = entryBits -- key and value size
129130
numEntriesFitInPage :: Fractional a => a
130131
numEntriesFitInPage = fromIntegral unusedPageBits / fromIntegral entryBitsWithOverhead
131132

133+
sessionSalt :: SessionSalt
134+
sessionSalt = SessionSalt 4
135+
132136
benchmarks :: Run.RunDataCaching -> IO ()
133137
benchmarks !caching = withFS $ \hfs hbio -> do
134138
#ifdef NO_IGNORE_ASSERTS
@@ -351,7 +355,7 @@ lookupsEnv runSizes keyRng0 hfs hbio caching = do
351355

352356
-- create the runs
353357
rbs <- sequence
354-
[ RunBuilder.new hfs hbio
358+
[ RunBuilder.new hfs hbio sessionSalt
355359
RunParams {
356360
runParamCaching = caching,
357361
runParamAlloc = RunAllocFixed benchmarkNumBitsPerEntry,
@@ -428,7 +432,7 @@ benchBloomQueries !bs !keyRng !n
428432
| n <= 0 = ()
429433
| otherwise =
430434
let (!ks, !keyRng') = genLookupBatch keyRng benchmarkGenBatchSize
431-
in bloomQueries bs ks `seq`
435+
in bloomQueries sessionSalt bs ks `seq`
432436
benchBloomQueries bs keyRng' (n-benchmarkGenBatchSize)
433437

434438
-- | This gives us the combined cost of calculating batches of keys, performing
@@ -445,7 +449,7 @@ benchIndexSearches !arenaManager !bs !ics !hs !keyRng !n
445449
| n <= 0 = pure ()
446450
| otherwise = do
447451
let (!ks, !keyRng') = genLookupBatch keyRng benchmarkGenBatchSize
448-
!rkixs = bloomQueries bs ks
452+
!rkixs = bloomQueries sessionSalt bs ks
449453
!_ioops <- withArena arenaManager $ \arena -> stToIO $ indexSearches arena ics hs ks rkixs
450454
benchIndexSearches arenaManager bs ics hs keyRng' (n-benchmarkGenBatchSize)
451455

@@ -463,7 +467,7 @@ benchPrepLookups !arenaManager !bs !ics !hs !keyRng !n
463467
| n <= 0 = pure ()
464468
| otherwise = do
465469
let (!ks, !keyRng') = genLookupBatch keyRng benchmarkGenBatchSize
466-
(!_rkixs, !_ioops) <- withArena arenaManager $ \arena -> stToIO $ prepLookups arena bs ics hs ks
470+
(!_rkixs, !_ioops) <- withArena arenaManager $ \arena -> stToIO $ prepLookups arena sessionSalt bs ics hs ks
467471
benchPrepLookups arenaManager bs ics hs keyRng' (n-benchmarkGenBatchSize)
468472

469473
-- | This gives us the combined cost of calculating batches of keys, and
@@ -489,7 +493,7 @@ benchLookupsIO !hbio !arenaManager !resolve !wb !wbblobs !rs !bs !ics !hs =
489493
| otherwise = do
490494
let (!ks, !keyRng') = genLookupBatch keyRng benchmarkGenBatchSize
491495
!_ <- lookupsIOWithWriteBuffer
492-
hbio arenaManager resolve wb wbblobs rs bs ics hs ks
496+
hbio arenaManager resolve sessionSalt wb wbblobs rs bs ics hs ks
493497
go keyRng' (n-benchmarkGenBatchSize)
494498

495499
{-------------------------------------------------------------------------------
@@ -524,7 +528,7 @@ classifyLookups !bs !keyRng0 !n0 =
524528
| otherwise =
525529
unsafePerformIO (putStr ".") `seq`
526530
let (!ks, !keyRng') = genLookupBatch keyRng benchmarkGenBatchSize
527-
!rkixs = bloomQueries bs ks
531+
!rkixs = bloomQueries sessionSalt bs ks
528532
in loop (positives + VP.length rkixs) keyRng' (n-benchmarkGenBatchSize)
529533

530534
-- | Fill a mutable vector with uniformly random values.

0 commit comments

Comments
 (0)