From 8f4d603dcdb8ea52eaf604d456c79a8ba5973408 Mon Sep 17 00:00:00 2001 From: Philipp Kant Date: Fri, 17 Jul 2015 14:57:11 +0200 Subject: [PATCH] Close thunk leak in roundstats. The function performFetches collects statistics about the requests performed in each round. However, the list is not evaluated (unless tracing is on), leading to an accumulation of thunks. Forcing the list via deepseq prevents this. --- Haxl/Core/Monad.hs | 3 ++- haxl.cabal | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Haxl/Core/Monad.hs b/Haxl/Core/Monad.hs index 5745e85..8ea50c4 100644 --- a/Haxl/Core/Monad.hs +++ b/Haxl/Core/Monad.hs @@ -56,6 +56,7 @@ import Control.Exception (AllocationLimitExceeded(..)) import Control.Monad import qualified Control.Exception as Exception import Control.Applicative hiding (Const) +import Control.DeepSeq import GHC.Exts (IsString(..)) #if __GLASGOW_HASKELL__ < 706 import Prelude hiding (catch) @@ -526,7 +527,7 @@ performFetches n env reqs = do let roundtime = realToFrac (diffUTCTime t1 t0) :: Double ifReport f 1 $ - modifyIORef' sref $ \(Stats rounds) -> + modifyIORef' sref $ \(Stats rounds) -> roundstats `deepseq` Stats (RoundStats (microsecs roundtime) dsroundstats: rounds) ifTrace f 1 $ diff --git a/haxl.cabal b/haxl.cabal index 73db83c..89983cc 100644 --- a/haxl.cabal +++ b/haxl.cabal @@ -31,6 +31,7 @@ library base == 4.*, bytestring >= 0.9 && < 0.11, containers == 0.5.*, + deepseq, directory >= 1.1 && < 1.3, filepath >= 1.3 && < 1.5, hashable == 1.2.*,