Cost of Overloading vs. HOFs
Simon Marlow
simonmarhaskell at gmail.com
Mon May 7 11:17:57 EDT 2007
Duncan Coutts wrote:
> On Fri, 2007-05-04 at 19:28 +0100, Adrian Hey wrote:
>> Hello,
>>
>> The GHC users guide says overloading "is death to performance if
>> left to linger in an inner loop" and one thing I noticed while
>> playing about with the AVL lib was that using a HOF and passing
>> the (overloaded) compare function as an explicit argument at the
>> start seemed to give noticable a performance boost (compared with
>> dictionary passing presumably).
>>
>> I'm not sure why that should be, but has anyone else noticed this?
>
> One might hope that in this case we could hoist the extraction of the
> dictionary members outside the inner loop.
In theory at least, case liberation (on with -O2) does this sort of thing.
(BTW Simon: it looks like -fliberate-case-threshold was replaced by
-fspec-threshold, but the change wasn't propagated to the docs).
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list