Do not run each individual stream action with captured state

We already run the whole thread with captured monad state (in doFork). Running
with captured state in parallel stream is unnecessary. This leads to buildup of
memory on thread stack and memory keeps growing continuously. Also with the
removal of this call we are at 8 seconds vs 34 seconds in concatMapBy parallel
benchmark.
This commit is contained in:
Harendra Kumar 2019-06-28 13:13:45 +05:30
parent 90161e172e
commit debe27702f

View File

@ -81,7 +81,6 @@ runOne st m0 winfo = go m0
else liftIO $ cleanupSVarFromWorker sv
sv = fromJust $ streamVar st
mrun = runInIO $ svarMrun sv
stop = liftIO $ do
incrementBufferLimit sv
@ -89,7 +88,7 @@ runOne st m0 winfo = go m0
sendStop sv winfo
sendit a = liftIO $ void $ send sv (ChildYield a)
single a = sendit a >> (liftIO $ sendStop sv winfo)
yieldk a r = sendit a >> (void $ liftIO $ mrun $ go r)
yieldk a r = sendit a >> go r
{-# NOINLINE forkSVarPar #-}
forkSVarPar :: (IsStream t, MonadAsync m)