[Haskell-cafe] Re: SCC accounting

Simon Marlow simonmar at microsoft.com
Wed Feb 1 06:23:19 EST 2006

Andrew Pimlott wrote:
> On Wed, Feb 01, 2006 at 12:28:59AM -0800, Andrew Pimlott wrote:
>> The Haskell code looks like
>>   predQuery pred = case lookup pred ctxIdx of Just f -> {-# SCC "pq.foo'" #-} f
>> Note that f is a function, which we expect to be expensive when it is
>> called.  However, that should be charged to the definition of the
>> function, right?
> We found a work-around:  We replaced f to the right of the annotation
> with
>     \z z2 z3 -> f z z2 z3
> and suddenly the right SCCs showed up in the profile (which enabled us
> to find the real leak, which was fixed by one strictness annotation).
> Actually, f takes 4 arguments, and forcing only 2 of them was not
> sufficient; in fact, forcing only 2 caused a different misleading SCC to
> dominate the profile!  I don't claim to understand why.

I don't understand why either, but I do know that cost-centre stacks 
behave strangely in some corner cases.  I have some examples stashed 
away somewhere, and it's been a long term ToDo item to really pin down 
the semantics of CCSs.  If you could encapsulate your example as a bug 
report (preferably make it as small as possible), that would be great.


More information about the Haskell-Cafe mailing list