-
Notifications
You must be signed in to change notification settings - Fork 23
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
Strange space leak in PBFT.ChainState #741
Comments
Stop-gap solution for #1356.
Stop-gap solution for #1356.
Stop-gap solution for #1356.
Stop-gap solution for #1356.
Stop-gap solution for #1356.
1357: Work around a strange space leak in PBFT.ChainState r=mrBliss a=mrBliss Includes a workaround for #1356. Additionally, squash all thunks introduced in the last month(s), so that the tests pass again when the `checktvarinvariant` flag is enabled for the `io-sim-classes` package. This boils down to replacing tuples with records with strict fields and forcing the elements of non-empty list to WHNF. Co-authored-by: Thomas Winant <thomas@well-typed.com>
More info from a past investigation: I have narrowed it down to GHC's Nosing through recent GHC tickets, I found https://gitlab.haskell.org/ghc/ghc/issues/16197, which might perhaps be related. One of the comments on that ticket says:
So let's hope that those changes indeed fixed the bug 🤞. We'll only now for sure when upgrading to a newer GHC version. |
It has been reported tthat IntersectMBO/ouroboros-network@f2a050b introduced a space leak. If we remove the following line, the space leak is gone: https://github.com/input-output-hk/ouroboros-network/blob/f2a050ba9ada3bf3ee2421f5e610947619d28337/ouroboros-consensus/src/Ouroboros/Consensus/Protocol/PBFT/ChainState.hs#L356
Note that the space leak has nothing to do with EBBs themselves! Even with an empty
ebbs
, we still have the space leak.Looking at the implementation of
pruneEBBsLT
: https://github.com/input-output-hk/ouroboros-network/blob/f2a050ba9ada3bf3ee2421f5e610947619d28337/ouroboros-consensus/src/Ouroboros/Consensus/Protocol/PBFT/ChainState.hs#L624No matter how I try to force
anchorSlot cs
(bangs,seq
, pass it in as an argument, ...), it causes a thunk in theStrictSeq
fields. Even if I pattern match on it, ignore it (!) and doMap.map id
instead of filtering. Strangely,cs { ebbs = ebbs }
doesn't have the leak.If we add
{-# OPTIONS_GHC -O0 #-}
to the module, the leak goes away. The leak is there with-O1
and-O2
(-fno-full-laziness
doesn't help). This makes me think the leak is caused by a bug in GHC 😱.You can use the following snippet to quickly detect the leak:
The thunk detection (
unsafeNoThunks
) will catch the thunk. Profiling the heap confirms that thunk detection is correct.The text was updated successfully, but these errors were encountered: