-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible Space Leak #340
Comments
The fact that the bottleneck is This could also be a victim of Edit: Admittedly, it feels funny that the final encoding of the free monad (which |
Verified the results. It is at least partly the absence of |
Sorry, I'm currently busy because of school+work - you can try looking into it, or as a temporary solution we could create separate branch with manually loopbreaked interpreters. |
I updated the stack.yaml file in the project I linked above to use ghc 8.10.1 and the current master versions of this repo and got the same results as before. Memory usage didn't seem to improve. |
I've been experiencing space leaking issues as well, and despite having made some laziness mistakes, when I broke it down I arrived at this test case: currentMemIO ::
IO Word64
currentMemIO = do
!s <- getRTSStats
pure (gcdetails_live_bytes . gc $ s)
currentMemRelIO ::
Word64 ->
IO Word64
currentMemRelIO base = do
cur <- currentMemIO
pure (cur - base)
memTestIO ::
Word64 ->
IO ()
memTestIO base = do
loop (0 :: Int)
where
loop n = do
when (n > 1000000) $ do
cur <- currentMemRelIO base
print cur
loop (if n > 1000000 then 0 else n + 1)
io :: IO ()
io = do
base <- currentMemIO
memTestIO base
memTestSem ::
Members '[Final IO] r =>
Word64 ->
Sem r ()
memTestSem base = do
loop (0 :: Int)
where
loop n = do
when (n > 1000000) $ do
cur <- embedFinal $ currentMemRelIO base
embedFinal $ print cur
loop (if n > 1000000 then 0 else n + 1)
sem :: IO ()
sem =
runFinal $
prg
where
prg = do
base <- embedFinal currentMemIO
memTestSem base The |
same behaviour with 8.10.1. |
Does this still happen using |
@isovector what do you mean by " |
@tek He means the test case you presented rewritten to use |
yep. executes a bit slower, but same memory growth. |
I've been using Polysemy in a larger project and have run into some memory problems. I was able to create a super simple example at https://github.com/jhgarner/Polysemy-Testing where I compare running computations with State in MTL and Polysemy. Instead of looking at speed, I'm exclusively looking at space efficiency. While the MTL example uses ~80KB of memory, Polysemy uses over 100MB. Could this be some kind of space leak in Polysemy or is there something I'm doing wrong in the code? Is this a laziness problem?
In the repo linked above, all of the code is in the src/Lib.hs file. Currently, Polysemy is commented out and the MTL version is active. There are also .hp and .svg files in the root of that project with the memory usages for both configurations.
The text was updated successfully, but these errors were encountered: