Really bad code for single method dictionaries?

I was reading the stream fusion code today and came across a comment stating that single element dictionaries interacted poorly with GHC's optimizer: class Unlifted a where [...] expose [...] -- | This makes GHC's optimiser happier; it sometimes produces really bad -- code for single-method dictionaries -- unlifted_dummy [...] A cursory search on GHC's Trac shows no corresponding bug; is this no longer a problem? A small problem? I would like to know more about it. -- Jason Dusek |...stream fusion code...| http://www.cse.unsw.edu.au/~dons/code/streams/list/Data/Stream.hs

Hi Jason,
While experimenting with Uniplate I found that 1-member dictionaries
were faster than N element dictionaries - which seems to run against
what you see in the comment. 1-member dictionaries being cheaper does
make sense as then instead of passing a tuple containing functions,
you can pass the direct function, and save yourself a (cheap) selector
call at every use.
Thanks
Neil
On Thu, Mar 26, 2009 at 11:29 PM, Jason Dusek
I was reading the stream fusion code today and came across a comment stating that single element dictionaries interacted poorly with GHC's optimizer:
class Unlifted a where
[...] expose [...]
-- | This makes GHC's optimiser happier; it sometimes produces really bad -- code for single-method dictionaries -- unlifted_dummy [...]
A cursory search on GHC's Trac shows no corresponding bug; is this no longer a problem? A small problem? I would like to know more about it.
-- Jason Dusek
|...stream fusion code...| http://www.cse.unsw.edu.au/~dons/code/streams/list/Data/Stream.hs _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

I don't think this is still the case. Roman, do you remember? - Don jason.dusek:
I was reading the stream fusion code today and came across a comment stating that single element dictionaries interacted poorly with GHC's optimizer:
class Unlifted a where
[...] expose [...]
-- | This makes GHC's optimiser happier; it sometimes produces really bad -- code for single-method dictionaries -- unlifted_dummy [...]
A cursory search on GHC's Trac shows no corresponding bug; is this no longer a problem? A small problem? I would like to know more about it.
-- Jason Dusek
|...stream fusion code...| http://www.cse.unsw.edu.au/~dons/code/streams/list/Data/Stream.hs _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

I would like to know more too. No one told me! Simon | -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users- | bounces@haskell.org] On Behalf Of Jason Dusek | Sent: 26 March 2009 23:30 | To: glasgow-haskell-users@haskell.org | Subject: Really bad code for single method dictionaries? | | I was reading the stream fusion code today and came across a comment stating | that single element dictionaries interacted poorly with GHC's optimizer: | | class Unlifted a where | | [...] | expose [...] | | -- | This makes GHC's optimiser happier; it sometimes produces really bad | -- code for single-method dictionaries | -- | unlifted_dummy [...] | | A cursory search on GHC's Trac shows no corresponding bug; is this no longer | a problem? A small problem? I would like to know more about it. | | -- | Jason Dusek | | | | |...stream fusion code...| | http://www.cse.unsw.edu.au/~dons/code/streams/list/Data/Stream.hs | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

2009/3/26 Jason Dusek
I was reading the stream fusion code today and came across a comment stating that single element dictionaries interacted poorly with GHC's optimizer:
class Unlifted a where
[...] expose [...]
-- | This makes GHC's optimiser happier; it sometimes produces really bad -- code for single-method dictionaries -- unlifted_dummy [...]
A cursory search on GHC's Trac shows no corresponding bug; is this no longer a problem? A small problem? I would like to know more about it.
I'm not sure if there is a bad interaction with rewrite rules (which I assume was the complaint) but single method dictionaries tend to be faster because they are represented by a coercion in the Core language, which means that packing and unpacking the dictionary is free at runtime. Cheers, Max
participants (6)
-
Don Stewart
-
Jason Dusek
-
Max Bolingbroke
-
Neil Mitchell
-
Roman Leshchinskiy
-
Simon Peyton-Jones