Containers and strictness

Johan Tibell johan.tibell at gmail.com
Thu Jul 1 11:54:09 EDT 2010


On Thu, Jul 1, 2010 at 3:38 AM, Felipe Lessa <felipe.lessa at gmail.com> wrote:

> On Wed, Jun 30, 2010 at 8:02 PM, Johan Tibell <johan.tibell at gmail.com>
> wrote:
> > On Thu, Jul 1, 2010 at 12:03 AM, Milan Straka <fox at ucw.cz> wrote:
> >> After suggestions by others I am thinking about
> >>  data Some elem = Single {-# UNPACK #-} !elem | More (Set elem)
> >> or
> >>  data Some elem = Single {-# UNPACK #-} !elem | More {-# UNPACK #-}
> !elem
> >> (Some elem)
> >
> > Unfortunately unpacking doesn't work for polymorphic fields (the new
> warning
> > for ineffective unpack pragmas in GHC head should warn about this). Given
> > this you might as well use a standard list.
>
> However strictness information does work.  But I don't know the answer
> for the following questions:
>
>  - Should the elements be strict even while they are not unpacked?
> Performance gains?
>
>  - Should the spine of the list be strict? Performance gains? Space leak
> gains?
>

In my experience/benchmarks strict spines are faster, probably due to better
cache usage as the whole structure is updated at once. All the container
data structures use strict spines.

Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/libraries/attachments/20100701/43ec186a/attachment.html


More information about the Libraries mailing list