Skip to content

Commit 53e7eab

Browse files
authored
Merge pull request #751 from IntersectMBO/jdral/trace-messages
Structure, refactor and clean up trace messages
2 parents 6bbc4a4 + 22d4997 commit 53e7eab

File tree

10 files changed

+613
-108
lines changed

10 files changed

+613
-108
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ jobs:
122122
--project-file="${{ matrix.cabal-project-file || env.DEFAULT_CABAL_PROJECT_FILE }}"
123123
124124
- name: 🧪 Test
125+
id: test
125126
if: ${{ !matrix.cabal-skip-tests }}
126127
run: |
127128
cabal test all \
@@ -131,6 +132,19 @@ jobs:
131132
env:
132133
TASTY_TIMEOUT: "5m"
133134

135+
# Golden test output is not printed to the screen, so if a golden test fails
136+
# then it is not clear from the logs why the test fails. Uploading the
137+
# directory containing the golden files after running the goldens tests
138+
# allows us to diff the expected and actual golden file contents.
139+
- name: 📦 Upload golden files
140+
if: ${{ !matrix.cabal-skip-tests && steps.test.outcome != 'success' && always() }}
141+
uses: actions/upload-artifact@v4
142+
with:
143+
name: golden-files-${{ runner.os }}-ghc-${{ steps.setup-haskell.outputs.ghc-version }}-cabal-${{ steps.setup-haskell.outputs.cabal-version }}-plan-${{ hashFiles('dist-newstyle/cache/plan.json') }}
144+
path: test/golden-file-data
145+
if-no-files-found: error
146+
retention-days: 1
147+
134148
- name: 🛠️ Setup cabal-docspec (Linux)
135149
if: ${{ !matrix.cabal-skip-tests && runner.os == 'Linux' }}
136150
uses: ./.github/actions/setup-cabal-docspec

lsm-tree.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ test-suite lsm-tree-test
845845
Test.Database.LSMTree.StateMachine
846846
Test.Database.LSMTree.StateMachine.DL
847847
Test.Database.LSMTree.StateMachine.Op
848+
Test.Database.LSMTree.Tracer.Golden
848849
Test.Database.LSMTree.UnitTests
849850
Test.FS
850851
Test.Util.Arbitrary

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)