-
Notifications
You must be signed in to change notification settings - Fork 15
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
CAD-406 fixed space leak in LogBuffer #502
Conversation
Signed-off-by: Alexander Diemand <codieplusplus@apax.net>
@@ -69,7 +69,7 @@ nameCounter (Counter RTSStats _ _) = "RTS" | |||
\subsubsection{CounterState}\label{code:CounterState}\index{CounterState} | |||
\begin{code} | |||
data CounterState = CounterState { | |||
csCounters :: [Counter] | |||
csCounters :: ![Counter] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this just force the list to WHNF. Using _
to indicate a thunk, this changes csCounters = _
into csCounters = _ : _
, so this is not forcing all the elements of the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this really is leaking space (we need some evidence for that first), then removing the bang is not the solution. Either use a stricter data structure than a list or force its contents (e.g., Cardano.Prelude.forceElemsToWHNF
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this does remove the memory leak, I have to admit that I'm still unable to completely figure out how the leak is occurring.
My assumption would be that the leak is happening because LogObject
is referenced here so it cannot be GC'd, but interestingly the bang pattern on lo
does no good.
Can you show a heap profile of before in addition to the one after? Otherwise, it seems like you're just adding bangs in random places. |
Signed-off-by: Alexander Diemand <codieplusplus@apax.net>
@CodiePP informed me that the JIRA issue has a heap profile before and after. Rather annoying that we have to start looking at multiple places now for information, instead of just GitHub, the place we are already using for issues, PRs, and code. |
description
LogBuffer
; this fix was possible with great input from @ksarictesting
1.) compile using
stack --nix --profile
2.) run using
stack --nix --profile exec example-complex -- +RTS -hc -L45 -RTS
3.) analyse:
hp2ps -c example-complex.hp
checklist
cabal new-clean; cabal new-build
)cabal new-test
)cd docs; nix-shell --run make
)