Skip to content

Commit 4c7c8fa

Browse files
committed
Structure, refactor and clean up trace messages
We give the trace message datatypes more structure (see the `$traces` Haddock section), and we add few new messages. In the process, we apply some minor refactorings to tracer calls and surrounding code.
1 parent d87f9fa commit 4c7c8fa

File tree

5 files changed

+362
-107
lines changed

5 files changed

+362
-107
lines changed

src/Database/LSMTree.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,13 @@ module Database.LSMTree (
185185
-- * Traces #traces#
186186
Tracer,
187187
LSMTreeTrace (..),
188+
SessionTrace (..),
188189
TableTrace (..),
189190
CursorTrace (..),
190191
MergeTrace (..),
191-
CursorId (..),
192+
SessionId (..),
192193
TableId (..),
194+
CursorId (..),
193195
AtLevel (..),
194196
LevelNo (..),
195197
NumEntries (..),
@@ -262,7 +264,8 @@ import Database.LSMTree.Internal.Unsafe (BlobRefInvalidError (..),
262264
ResolveSerialisedValue, SessionClosedError (..),
263265
SessionDirCorruptedError (..),
264266
SessionDirDoesNotExistError (..),
265-
SessionDirLockedError (..), SnapshotCorruptedError (..),
267+
SessionDirLockedError (..), SessionId (..),
268+
SessionTrace (..), SnapshotCorruptedError (..),
266269
SnapshotDoesNotExistError (..), SnapshotExistsError (..),
267270
SnapshotNotCompatibleError (..), TableClosedError (..),
268271
TableCorruptedError (..), TableTooLargeError (..),

src/Database/LSMTree/Internal/RunReader.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ data RunReader m h = RunReader {
9090
}
9191

9292
data OffsetKey = NoOffsetKey | OffsetKey !SerialisedKey
93+
deriving stock Show
9394

9495
{-# SPECIALISE new ::
9596
OffsetKey

src/Database/LSMTree/Internal/UniqCounter.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Database.LSMTree.Internal.UniqCounter (
1111
uniqueToCursorId,
1212
) where
1313

14+
import Control.DeepSeq (NFData (..))
1415
import Control.Monad.Primitive (PrimMonad, PrimState)
1516
import Data.Primitive.PrimVar as P
1617
import Database.LSMTree.Internal.RunNumber
@@ -35,6 +36,9 @@ uniqueToCursorId (Unique n) = CursorId n
3536
--
3637
newtype UniqCounter m = UniqCounter (PrimVar (PrimState m) Int)
3738

39+
instance NFData (UniqCounter m) where
40+
rnf (UniqCounter (P.PrimVar mba)) = rnf mba
41+
3842
{-# INLINE newUniqCounter #-}
3943
newUniqCounter :: PrimMonad m => Int -> m (UniqCounter m)
4044
newUniqCounter = fmap UniqCounter . P.newPrimVar

0 commit comments

Comments
 (0)