@@ -574,23 +574,27 @@ getChunkInfo ::
574
574
getChunkInfo cacheEnv chunk = do
575
575
lastUsed <- LastUsed <$> getMonotonicTime
576
576
-- Make sure we don't leave an empty MVar in case of an exception.
577
- mbCacheHit <- modifyMVar cacheVar $
577
+ ( mbCacheHit, tr) <- modifyMVar cacheVar $
578
578
\ cached@ Cached { currentChunk, currentChunkInfo, nbPastChunks } -> if
579
579
| chunk == currentChunk -> do
580
580
-- Cache hit for the current chunk
581
- traceWith tracer $ TraceCurrentChunkHit chunk nbPastChunks
582
- return (cached, Just $ Left currentChunkInfo)
581
+ return ( cached
582
+ , (Just $ Left currentChunkInfo, TraceCurrentChunkHit chunk nbPastChunks)
583
+ )
583
584
| Just (pastChunkInfo, cached') <- lookupPastChunkInfo chunk lastUsed cached -> do
584
585
-- Cache hit for an chunk in the past
585
- traceWith tracer $ TracePastChunkHit chunk nbPastChunks
586
- return (cached', Just $ Right pastChunkInfo)
586
+ return ( cached'
587
+ , (Just $ Right pastChunkInfo, TracePastChunkHit chunk nbPastChunks)
588
+ )
587
589
| otherwise -> do
588
590
-- Cache miss for an chunk in the past. We don't want to hold on to
589
591
-- the 'cacheVar' MVar, blocking all other access to the cace, while
590
592
-- we're reading things from disk, so put it back now and update the
591
593
-- cache afterwards.
592
- traceWith tracer $ TracePastChunkMiss chunk nbPastChunks
593
- return (cached, Nothing )
594
+ return ( cached
595
+ , (Nothing , TracePastChunkMiss chunk nbPastChunks)
596
+ )
597
+ traceWith tracer tr
594
598
case mbCacheHit of
595
599
Just hit -> return hit
596
600
Nothing -> do
0 commit comments