Skip to content

Commit b7111fe

Browse files
committed
Callstacks
1 parent 2783e7c commit b7111fe

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

src/Database/LSMTree/Internal/MergeSchedule.hs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ import Database.LSMTree.Internal.WriteBuffer (WriteBuffer)
8383
import qualified Database.LSMTree.Internal.WriteBuffer as WB
8484
import Database.LSMTree.Internal.WriteBufferBlobs (WriteBufferBlobs)
8585
import qualified Database.LSMTree.Internal.WriteBufferBlobs as WBB
86+
import GHC.Stack (HasCallStack)
8687
import qualified System.FS.API as FS
8788
import System.FS.API (HasFS)
8889
import System.FS.BlockIO.API (HasBlockIO)
@@ -198,14 +199,15 @@ data LevelsCache m h = LevelsCache_ {
198199
}
199200

200201
{-# SPECIALISE mkLevelsCache ::
201-
ActionRegistry IO
202+
HasCallStack
203+
=> ActionRegistry IO
202204
-> Levels IO h
203205
-> IO (LevelsCache IO h) #-}
204206
-- | Flatten the argument 'Level's into a single vector of runs, including all
205207
-- runs that are inputs to an ongoing merge. Use that to populate the
206208
-- 'LevelsCache'. The cache will take a reference for each of its runs.
207209
mkLevelsCache ::
208-
forall m h. (PrimMonad m, MonadMVar m, MonadMask m)
210+
forall m h. (HasCallStack, PrimMonad m, MonadMVar m, MonadMask m)
209211
=> ActionRegistry m
210212
-> Levels m h
211213
-> m (LevelsCache m h)
@@ -239,7 +241,8 @@ mkLevelsCache reg lvls = do
239241
(incoming <>) . fold <$> V.forM rs k1
240242

241243
{-# SPECIALISE rebuildCache ::
242-
ActionRegistry IO
244+
HasCallStack
245+
=> ActionRegistry IO
243246
-> LevelsCache IO h
244247
-> Levels IO h
245248
-> IO (LevelsCache IO h) #-}
@@ -264,7 +267,7 @@ mkLevelsCache reg lvls = do
264267
-- a solution to keep blob references valid until the next /update/ comes along.
265268
-- Lookups should no invalidate blob erferences.
266269
rebuildCache ::
267-
(PrimMonad m, MonadMVar m, MonadMask m)
270+
(HasCallStack, PrimMonad m, MonadMVar m, MonadMask m)
268271
=> ActionRegistry m
269272
-> LevelsCache m h -- ^ old cache
270273
-> Levels m h -- ^ new levels
@@ -274,11 +277,12 @@ rebuildCache reg oldCache newLevels = do
274277
mkLevelsCache reg newLevels
275278

276279
{-# SPECIALISE duplicateLevelsCache ::
277-
ActionRegistry IO
280+
HasCallStack
281+
=> ActionRegistry IO
278282
-> LevelsCache IO h
279283
-> IO (LevelsCache IO h) #-}
280284
duplicateLevelsCache ::
281-
(PrimMonad m, MonadMask m)
285+
(HasCallStack, PrimMonad m, MonadMask m)
282286
=> ActionRegistry m
283287
-> LevelsCache m h
284288
-> m (LevelsCache m h)
@@ -288,11 +292,12 @@ duplicateLevelsCache reg cache = do
288292
pure cache { cachedRuns = rs' }
289293

290294
{-# SPECIALISE releaseLevelsCache ::
291-
ActionRegistry IO
295+
HasCallStack
296+
=> ActionRegistry IO
292297
-> LevelsCache IO h
293298
-> IO () #-}
294299
releaseLevelsCache ::
295-
(PrimMonad m, MonadMask m)
300+
(HasCallStack, PrimMonad m, MonadMask m)
296301
=> ActionRegistry m
297302
-> LevelsCache m h
298303
-> m ()

src/Database/LSMTree/Internal/MergingRun.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,11 @@ unsafeNew mergeDebt (SpentCredits spentCredits)
268268
-- @withRollback reg (duplicateRuns mr) (mapM_ releaseRef)@ isn't exception-safe
269269
-- since if one of the @releaseRef@ calls fails, the following ones aren't run.
270270
{-# SPECIALISE duplicateRuns ::
271-
Ref (MergingRun t IO h) -> IO (V.Vector (Ref (Run IO h))) #-}
271+
HasCallStack
272+
=> Ref (MergingRun t IO h)
273+
-> IO (V.Vector (Ref (Run IO h))) #-}
272274
duplicateRuns ::
273-
(PrimMonad m, MonadMVar m, MonadMask m)
275+
(HasCallStack, PrimMonad m, MonadMVar m, MonadMask m)
274276
=> Ref (MergingRun t m h)
275277
-> m (V.Vector (Ref (Run m h)))
276278
duplicateRuns (DeRef mr) =

src/Database/LSMTree/Internal/RunReader.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import Database.LSMTree.Internal.RawOverflowPage (RawOverflowPage,
4949
import Database.LSMTree.Internal.RawPage
5050
import qualified Database.LSMTree.Internal.Run as Run
5151
import Database.LSMTree.Internal.Serialise
52+
import GHC.Stack (HasCallStack)
5253
import qualified System.FS.API as FS
5354
import System.FS.API (HasFS)
5455
import qualified System.FS.BlockIO.API as FS
@@ -93,11 +94,12 @@ data OffsetKey = NoOffsetKey | OffsetKey !SerialisedKey
9394
deriving stock Show
9495

9596
{-# SPECIALISE new ::
96-
OffsetKey
97+
HasCallStack
98+
=> OffsetKey
9799
-> Ref (Run.Run IO h)
98100
-> IO (RunReader IO h) #-}
99101
new :: forall m h.
100-
(MonadMask m, MonadSTM m, PrimMonad m)
102+
(HasCallStack, MonadMask m, MonadSTM m, PrimMonad m)
101103
=> OffsetKey
102104
-> Ref (Run.Run m h)
103105
-> m (RunReader m h)

0 commit comments

Comments
 (0)