on master help sign in
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.

commitdebe27702fe3233ba05f03d8bebf4f32be416e3f authorHarendra Kumar <harendra.kumar@gmail.com> dateFri 28 Jun 2019, 13:13 (7 years ago) parent90161e1
1 file changed+1−2
src/Streamly/Streams/Parallel.hs+1−2
src/Streamly/Streams/Parallel.hs+1−2
@@ -81,7 +81,6 @@ runOne st m0 winfo = go m0
8181 else liftIO $ cleanupSVarFromWorker sv
8282
8383 sv = fromJust $ streamVar st
84− mrun = runInIO $ svarMrun sv
8584
8685 stop = liftIO $ do
8786 incrementBufferLimit sv
@@ -89,7 +88,7 @@ runOne st m0 winfo = go m0
8988 sendStop sv winfo
9089 sendit a = liftIO $ void $ send sv (ChildYield a)
9190 single a = sendit a >> (liftIO $ sendStop sv winfo)
92− yieldk a r = sendit a >> (void $ liftIO $ mrun $ go r)
91+ yieldk a r = sendit a >> go r
9392
9493{-# NOINLINE forkSVarPar #-}
9594forkSVarPar :: (IsStream t, MonadAsync m)