Skip to content

Commit

Permalink
Add more strictness to resolve NoThunks test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoutts committed Nov 30, 2024
1 parent e874142 commit 4e2998f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src-control/Control/RefCount.hs
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,12 @@ deRefWeak (WeakRef obj) = do
#ifndef NO_IGNORE_ASSERTS
newRefWithTracker :: PrimMonad m => obj -> m (Ref obj)
newRefWithTracker obj =
return (Ref obj)
return $! Ref obj
#else
newRefWithTracker :: (PrimMonad m, HasCallStack) => obj -> m (Ref obj)
newRefWithTracker obj = do
reftracker' <- newRefTracker callStack
return (Ref obj reftracker')
return $! Ref obj reftracker'
#endif

data RefException =
Expand Down
6 changes: 4 additions & 2 deletions src-control/Control/TempRegistry.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ allocateTemp :: (MonadMask m, MonadMVar m) =>
-> m a
-> (a -> m ())
-> m a
allocateTemp reg acquire free = mustBeRight <$> allocateEitherTemp reg (fmap Right acquire) free
allocateTemp reg acquire free =
mustBeRight <$!> allocateEitherTemp reg (fmap Right acquire) free
where
mustBeRight :: Either Void a -> a
mustBeRight (Left v) = absurd v
Expand All @@ -128,7 +129,8 @@ allocateMaybeTemp ::
-> m (Maybe a)
-> (a -> m ())
-> m (Maybe a)
allocateMaybeTemp reg acquire free = fromEither <$!> allocateEitherTemp reg (toEither <$> acquire) free
allocateMaybeTemp reg acquire free =
fromEither <$!> allocateEitherTemp reg (toEither <$> acquire) free
where
toEither :: Maybe a -> Either () a
toEither Nothing = Left ()
Expand Down
6 changes: 3 additions & 3 deletions src/Database/LSMTree/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ data CursorEnv m h = CursorEnv {

-- | The write buffer blobs, which like the runs, we have to keep open
-- untile the cursor is closed.
, cursorWBB :: Ref (WBB.WriteBufferBlobs m h)
, cursorWBB :: !(Ref (WBB.WriteBufferBlobs m h))
}

{-# SPECIALISE withCursor ::
Expand Down Expand Up @@ -969,8 +969,8 @@ newCursor !offsetKey t = withOpenTable t $ \thEnv -> do
-- references to each run, so it is safe.
dupTableContent reg contentVar = do
RW.withReadAccess contentVar $ \content -> do
let wb = tableWriteBuffer content
wbblobs = tableWriteBufferBlobs content
let !wb = tableWriteBuffer content
!wbblobs = tableWriteBufferBlobs content
wbblobs' <- allocateTemp reg (dupRef wbblobs) releaseRef
let runs = cachedRuns (tableCache content)
runs' <- V.forM runs $ \r ->
Expand Down
6 changes: 3 additions & 3 deletions src/Database/LSMTree/Internal/MergeSchedule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ duplicateTableContent reg (TableContent wb wbb levels cache) = do
wbb' <- allocateTemp reg (dupRef wbb) releaseRef
levels' <- duplicateLevels reg levels
cache' <- duplicateLevelsCache reg cache
return $ TableContent wb wbb' levels' cache'
return $! TableContent wb wbb' levels' cache'

{-# SPECIALISE releaseTableContent :: TempRegistry IO -> TableContent IO h -> IO () #-}
releaseTableContent ::
Expand Down Expand Up @@ -441,7 +441,7 @@ duplicateLevels reg levels =
incomingRun' <- duplicateIncomingRun reg incomingRun
residentRuns' <- V.forM residentRuns $ \r ->
allocateTemp reg (dupRef r) releaseRef
return Level {
return $! Level {
incomingRun = incomingRun',
residentRuns = residentRuns'
}
Expand Down Expand Up @@ -787,7 +787,7 @@ addRunToLevels tr conf@TableConfig{..} resolve hfs hbio root uc r0 reg levels =
-- Make a new level
let policyForLevel = mergePolicyForLevel confMergePolicy ln V.empty
ir <- newMerge policyForLevel Merge.LastLevel ln rs
return $ V.singleton $ Level ir V.empty
return $! V.singleton $ Level ir V.empty
go !ln rs' (V.uncons -> Just (Level ir rs, ls)) = do
r <- expectCompletedMergeTraced ln ir
case mergePolicyForLevel confMergePolicy ln ls of
Expand Down

0 comments on commit 4e2998f

Please sign in to comment.