summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2026-05-08 01:04:31 +0200
committerTom Smeding <tom@tomsmeding.com>2026-05-08 01:04:31 +0200
commit80ba594a6b44b9693eeaa27bf3bea225a57527ca (patch)
tree448e17c7b6a58f1ddc73273c003949c9a80d3ac8
parent1446fba192da53cd0f6382b99a53bd1467f98bb6 (diff)
Eliminate some thunks
This saves ALL the memory; all files were previously kept in memory
-rw-r--r--src/Config.hs2
-rw-r--r--src/Index.hs6
2 files changed, 5 insertions, 3 deletions
diff --git a/src/Config.hs b/src/Config.hs
index ffd4875..d6cf021 100644
--- a/src/Config.hs
+++ b/src/Config.hs
@@ -69,7 +69,7 @@ type family IfFull stage a where
IfFull Full a = a
-- | network, channelname
-data Channel = Channel { chanNetwork :: Text, chanChannel :: Text }
+data Channel = Channel { chanNetwork :: !Text, chanChannel :: !Text }
deriving (Show, Eq, Ord)
prettyChannel :: Channel -> Text
diff --git a/src/Index.hs b/src/Index.hs
index bdc3751..89a24e3 100644
--- a/src/Index.hs
+++ b/src/Index.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
@@ -95,14 +96,15 @@ initIndex basedir toimport = do
Nothing -> error $ "Log file with unexpected file name: " ++ path
-- atomicPrintS $ "Parsing " ++ path ++ " (" ++ show date ++ " -> " ++ show (dateToDay date) ++ ")"
events <- parseLog <$> BS.readFile path
- return (uncurry3 fromGregorian date, length events)
+ let !nevents = length events
+ return (uncurry3 fromGregorian date, nevents)
let minday = minimum (map fst days)
maxday = maximum (map fst days)
ndays = fromIntegral @Integer @Int (diffDays maxday minday + 1)
-- traceM $ nw ++ "/" ++ ch ++ ": days = " ++ show [(toFileName (dayToYMD d), i) | (d, i) <- days]
let countScan = IGV.fromListN ndays (drop 1 $ scanl' (+) 0 (makeCounts [minday..maxday] days))
ntotal = sum (map snd days)
- chanindex <- newIORef $
+ chanindex <- newIORef $!
ChanIndex { ciStartDay = minday
, ciCountUntil = countScan
, ciTotal = ntotal }