Skip to content

Commit a7114d1

Browse files
committed
Lookup micro bench: use WriteBufferBlobs from env
This fixes the file paths errors for the write buffer blobs. It is also generally the right direction to go: If we ever want these tests to work with a write buffer and blobs, lookups must look at the original write buffer blobs, not an empty one.
1 parent 8c06336 commit a7114d1

File tree

1 file changed

+14
-14
lines changed
  • bench/micro/Bench/Database/LSMTree/Internal

1 file changed

+14
-14
lines changed

bench/micro/Bench/Database/LSMTree/Internal/Lookup.hs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ benchmarks = bgroup "Bench.Database.LSMTree.Internal.Lookup" [
8383

8484
benchLookups :: Config -> Benchmark
8585
benchLookups conf@Config{name} =
86-
withEnv $ \ ~(_dir, arenaManager, hasFS, hasBlockIO, rs, ks) ->
86+
withEnv $ \ ~(_dir, arenaManager, _hasFS, hasBlockIO, wbblobs, rs, ks) ->
8787
env ( pure ( V.map (\(DeRef r) -> Run.runFilter r) rs
8888
, V.map (\(DeRef r) -> Run.runIndex r) rs
8989
, V.map (\(DeRef r) -> Run.runKOpsFile r) rs
@@ -126,28 +126,24 @@ benchLookups conf@Config{name} =
126126
( do arena <- newArena arenaManager
127127
(rkixs, ioops) <- stToIO (prepLookups arena blooms indexes kopsFiles ks)
128128
ioress <- FS.submitIO hasBlockIO ioops
129-
wbblobs <- WBB.new hasFS (FS.mkFsPath [])
130-
pure (rkixs, ioops, ioress, arena, wbblobs)
129+
pure (rkixs, ioops, ioress, arena)
131130
)
132-
(\(_, _, _, arena, wbblobs) -> do
133-
closeArena arenaManager arena
134-
releaseRef wbblobs)
135-
(\ ~(rkixs, ioops, ioress, _, wbblobs_unused) -> do
136-
!_ <- intraPageLookups resolveV WB.empty wbblobs_unused
131+
(\(_, _, _, arena) -> closeArena arenaManager arena)
132+
(\ ~(rkixs, ioops, ioress, _) -> do
133+
!_ <- intraPageLookups resolveV WB.empty wbblobs
137134
rs ks rkixs ioops ioress
138135
pure ())
139136
-- The whole shebang: lookup preparation, doing the IO, and then
140137
-- performing intra-page-lookups. Again, we evaluate the result to
141138
-- WHNF because it is the same result that intraPageLookups produces
142139
-- (see above).
143-
, let wb_unused = WB.empty in
144-
env (WBB.new hasFS (FS.mkFsPath [])) $ \wbblobs_unused ->
145-
bench "Lookups in IO" $
140+
, bench "Lookups in IO" $
146141
whnfAppIO (\ks' -> lookupsIO hasBlockIO arenaManager resolveV
147-
wb_unused wbblobs_unused
142+
WB.empty wbblobs
148143
rs blooms indexes kopsFiles ks') ks
149144
]
150-
--TODO: consider adding benchmarks that also use the write buffer
145+
-- TODO: consider adding benchmarks that also use the write buffer
146+
-- (then we can't just use 'WB.empty', but must take it from the env)
151147
where
152148
withEnv = envWithCleanup
153149
(lookupsInBatchesEnv conf)
@@ -181,6 +177,7 @@ lookupsInBatchesEnv ::
181177
, ArenaManager RealWorld
182178
, FS.HasFS IO FS.HandleIO
183179
, FS.HasBlockIO IO FS.HandleIO
180+
, Ref (WBB.WriteBufferBlobs IO FS.HandleIO)
184181
, V.Vector (Ref (Run IO FS.HandleIO))
185182
, V.Vector SerialisedKey
186183
)
@@ -203,6 +200,7 @@ lookupsInBatchesEnv Config {..} = do
203200
, arenaManager
204201
, hasFS
205202
, hasBlockIO
203+
, wbblobs
206204
, V.singleton r
207205
, lookupKeys
208206
)
@@ -212,13 +210,15 @@ lookupsInBatchesCleanup ::
212210
, ArenaManager RealWorld
213211
, FS.HasFS IO FS.HandleIO
214212
, FS.HasBlockIO IO FS.HandleIO
213+
, Ref (WBB.WriteBufferBlobs IO FS.HandleIO)
215214
, V.Vector (Ref (Run IO FS.HandleIO))
216215
, V.Vector SerialisedKey
217216
)
218217
-> IO ()
219-
lookupsInBatchesCleanup (tmpDir, _arenaManager, _hasFS, hasBlockIO, rs, _) = do
218+
lookupsInBatchesCleanup (tmpDir, _arenaManager, _hasFS, hasBlockIO, wbblobs, rs, _) = do
220219
FS.close hasBlockIO
221220
forM_ rs releaseRef
221+
releaseRef wbblobs
222222
removeDirectoryRecursive tmpDir
223223

224224
-- | Generate keys to store and keys to lookup

0 commit comments

Comments
 (0)