Skip to content

Structure, refactor and clean up trace messages #751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ jobs:
--project-file="${{ matrix.cabal-project-file || env.DEFAULT_CABAL_PROJECT_FILE }}"

- name: 🧪 Test
id: test
if: ${{ !matrix.cabal-skip-tests }}
run: |
cabal test all \
Expand All @@ -131,6 +132,19 @@ jobs:
env:
TASTY_TIMEOUT: "5m"

# Golden test output is not printed to the screen, so if a golden test fails
# then it is not clear from the logs why the test fails. Uploading the
# directory containing the golden files after running the goldens tests
# allows us to diff the expected and actual golden file contents.
- name: 📦 Upload golden files
if: ${{ !matrix.cabal-skip-tests && steps.test.outcome != 'success' && always() }}
uses: actions/upload-artifact@v4
with:
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') }}
path: test/golden-file-data
if-no-files-found: error
retention-days: 1

- name: 🛠️ Setup cabal-docspec (Linux)
if: ${{ !matrix.cabal-skip-tests && runner.os == 'Linux' }}
uses: ./.github/actions/setup-cabal-docspec
Expand Down
1 change: 1 addition & 0 deletions lsm-tree.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ test-suite lsm-tree-test
Test.Database.LSMTree.StateMachine
Test.Database.LSMTree.StateMachine.DL
Test.Database.LSMTree.StateMachine.Op
Test.Database.LSMTree.Tracer.Golden
Test.Database.LSMTree.UnitTests
Test.FS
Test.Util.Arbitrary
Expand Down
7 changes: 5 additions & 2 deletions src/Database/LSMTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,13 @@ module Database.LSMTree (
-- * Traces #traces#
Tracer,
LSMTreeTrace (..),
SessionTrace (..),
TableTrace (..),
CursorTrace (..),
MergeTrace (..),
CursorId (..),
SessionId (..),
TableId (..),
CursorId (..),
AtLevel (..),
LevelNo (..),
NumEntries (..),
Expand Down Expand Up @@ -251,7 +253,8 @@ import Database.LSMTree.Internal.Unsafe (BlobRefInvalidError (..),
ResolveSerialisedValue, SessionClosedError (..),
SessionDirCorruptedError (..),
SessionDirDoesNotExistError (..),
SessionDirLockedError (..), SnapshotCorruptedError (..),
SessionDirLockedError (..), SessionId (..),
SessionTrace (..), SnapshotCorruptedError (..),
SnapshotDoesNotExistError (..), SnapshotExistsError (..),
SnapshotNotCompatibleError (..), TableClosedError (..),
TableCorruptedError (..), TableTooLargeError (..),
Expand Down
1 change: 1 addition & 0 deletions src/Database/LSMTree/Internal/RunReader.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ data RunReader m h = RunReader {
}

data OffsetKey = NoOffsetKey | OffsetKey !SerialisedKey
deriving stock Show

{-# SPECIALISE new ::
OffsetKey
Expand Down
4 changes: 4 additions & 0 deletions src/Database/LSMTree/Internal/UniqCounter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Database.LSMTree.Internal.UniqCounter (
uniqueToCursorId,
) where

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

instance NFData (UniqCounter m) where
rnf (UniqCounter (P.PrimVar mba)) = rnf mba

{-# INLINE newUniqCounter #-}
newUniqCounter :: PrimMonad m => Int -> m (UniqCounter m)
newUniqCounter = fmap UniqCounter . P.newPrimVar
Expand Down
Loading