Skip to content

Commit dd8aac1

Browse files
authored
Merge pull request #334 from IntersectMBO/jdral/mutvar-for-ioref
Replace `IORef` by `MutVar`
2 parents 2936863 + 3a93441 commit dd8aac1

File tree

15 files changed

+202
-188
lines changed

15 files changed

+202
-188
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ lookupsEnv ::
318318
-> FS.HasFS IO FS.HandleIO
319319
-> FS.HasBlockIO IO FS.HandleIO
320320
-> Run.RunDataCaching
321-
-> IO ( V.Vector (Run (FS.Handle FS.HandleIO))
321+
-> IO ( V.Vector (Run RealWorld (FS.Handle FS.HandleIO))
322322
, V.Vector (Bloom SerialisedKey)
323323
, V.Vector IndexCompact
324324
, V.Vector (FS.Handle FS.HandleIO)
@@ -452,7 +452,7 @@ benchLookupsIO ::
452452
FS.HasBlockIO IO h
453453
-> ArenaManager RealWorld
454454
-> ResolveSerialisedValue
455-
-> V.Vector (Run (FS.Handle h))
455+
-> V.Vector (Run RealWorld (FS.Handle h))
456456
-> V.Vector (Bloom SerialisedKey)
457457
-> V.Vector IndexCompact
458458
-> V.Vector (FS.Handle h)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ lookupsInBatchesEnv ::
167167
, ArenaManager RealWorld
168168
, FS.HasFS IO FS.HandleIO
169169
, FS.HasBlockIO IO FS.HandleIO
170-
, V.Vector (Run (FS.Handle FS.HandleIO))
170+
, V.Vector (Run RealWorld (FS.Handle FS.HandleIO))
171171
, V.Vector SerialisedKey
172172
)
173173
lookupsInBatchesEnv Config {..} = do
@@ -198,7 +198,7 @@ lookupsInBatchesCleanup ::
198198
, ArenaManager RealWorld
199199
, FS.HasFS IO FS.HandleIO
200200
, FS.HasBlockIO IO FS.HandleIO
201-
, V.Vector (Run (FS.Handle FS.HandleIO))
201+
, V.Vector (Run RealWorld (FS.Handle FS.HandleIO))
202202
, V.Vector SerialisedKey
203203
)
204204
-> IO ()

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Bench.Database.LSMTree.Internal.Merge (benchmarks) where
22

33
import Control.Monad (when, zipWithM)
4+
import Control.Monad.Primitive
45
import Criterion.Main (Benchmark, bench, bgroup)
56
import qualified Criterion.Main as Cr
67
import Data.Bifunctor (first)
@@ -226,7 +227,7 @@ merge ::
226227
-> Config
227228
-> Run.RunFsPaths
228229
-> InputRuns
229-
-> IO (Run (FS.Handle (FS.HandleIO)))
230+
-> IO (Run RealWorld (FS.Handle (FS.HandleIO)))
230231
merge fs hbio Config {..} targetPaths runs = do
231232
let f = fromMaybe const mergeMappend
232233
m <- fromMaybe (error "empty inputs, no merge created") <$>
@@ -244,7 +245,7 @@ outputRunPaths = RunFsPaths (FS.mkFsPath []) 0
244245
inputRunPaths :: [Run.RunFsPaths]
245246
inputRunPaths = RunFsPaths (FS.mkFsPath []) <$> [1..]
246247

247-
type InputRuns = [Run (FS.Handle FS.HandleIO)]
248+
type InputRuns = [Run RealWorld (FS.Handle FS.HandleIO)]
248249

249250
type Mappend = SerialisedValue -> SerialisedValue -> SerialisedValue
250251

@@ -360,7 +361,7 @@ createRun ::
360361
-> Maybe Mappend
361362
-> Run.RunFsPaths
362363
-> [SerialisedKOp]
363-
-> IO (Run (FS.Handle h))
364+
-> IO (Run RealWorld (FS.Handle h))
364365
createRun hasFS hasBlockIO mMappend targetPath =
365366
Run.fromWriteBuffer hasFS hasBlockIO Run.CacheRunData (RunAllocFixed 10) targetPath
366367
. Fold.foldl insert WB.empty

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Bench.Database.LSMTree.Internal.WriteBuffer (benchmarks) where
22

33
import Control.DeepSeq (NFData (..))
4+
import Control.Monad.Primitive
45
import Criterion.Main (Benchmark, bench, bgroup)
56
import qualified Criterion.Main as Cr
67
import Data.Bifunctor (first)
@@ -166,7 +167,7 @@ flush :: FS.HasFS IO FS.HandleIO
166167
-> FS.HasBlockIO IO FS.HandleIO
167168
-> RunFsPaths
168169
-> WriteBuffer
169-
-> IO (Run (FS.Handle (FS.HandleIO)))
170+
-> IO (Run RealWorld (FS.Handle (FS.HandleIO)))
170171
flush hfs hbio = Run.fromWriteBuffer hfs hbio Run.CacheRunData (RunAllocFixed 10)
171172

172173
data InputKOps

src/Database/LSMTree/Common.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import Control.Concurrent.Class.MonadMVar.Strict
2929
import Control.Concurrent.Class.MonadSTM (MonadSTM, STM)
3030
import Control.DeepSeq
3131
import Control.Monad.Class.MonadThrow
32+
import Control.Monad.Primitive (PrimMonad (..))
3233
import Data.Kind (Type)
3334
import Data.Typeable (Proxy, Typeable)
3435
import qualified Database.LSMTree.Internal as Internal
@@ -216,4 +217,4 @@ listSnapshots (Session sesh) = Internal.listSnapshots sesh
216217
-- TODO: get rid of the @m@ parameter?
217218
type BlobRef :: (Type -> Type) -> Type -> Type
218219
type role BlobRef nominal nominal
219-
data BlobRef m blob = forall h. Typeable h => BlobRef (Internal.BlobRef (Internal.Run h))
220+
data BlobRef m blob = forall h. Typeable h => BlobRef (Internal.BlobRef (Internal.Run (PrimState m) h))

0 commit comments

Comments
 (0)