
David Feuer
On Monday, January 30, 2017 9:50:56 PM EST Simon Marlow wrote:
Unfortunately the mechanisms we have right now to fix it aren't ideal - noDuplicate# is a bigger hammer than we need.
Do you think you could explain this a bit more? What aspect of nuDuplicate# is overkill? What does it guard against that can't happen here?
I suspect Simon is referring to the fact that noDuplicate# actually needs to call back into the RTS to claim ownership over all thunks on the stack before it can proceed.
All we really need is some way to make a thunk atomic, it would require some special entry code to the thunk which did atomic eager-blackholing. Hmm, now that I think about it, perhaps we could just have a flag, -fatomic-eager-blackholing.
Indeed this sounds quite reasonable.
If it's possible to use a primop to do this "locally", I think it would be very nice to get that as well as a global flag. If it affects code generation in an inherently global fashion, then of course we'll just have to live with that, and lots of NOINLINE.
I guess something like, eagerlyBlackhole :: a -> a Which would be lowered to a bit of code which would do eagerly blackhole the thunk before entering it? Cheers, - Ben