[Haskell-cafe] Re: Fwd: Semantics of iteratees, enumerators, enumeratees?

John Lato jwlato at gmail.com
Wed Aug 25 07:53:47 EDT 2010


>
> From: Heinrich Apfelmus <apfelmus at quantentunnel.de>
>
> Jason Dagit wrote:
> > Heinrich Apfelmus wrote:
> >>
> >> I'm curious, can you give an example where you want to be explicit about
> >> chunking? I have a hard time imagining an example where chunking is
> >> beneficial compared to getting each character in sequence. Chunking
> >> seems to be common in C for reasons of performance, but how does that
> >> apply to Haskell?
> >
> > [...]
> > I think it basically comes down to this: We replace lazy io with explicit
> > chunking because lazy io is unsafe, but explicit chunking can be safe.
>
> Ah, I mean to compare Iteratees with chunking to Iteratees with single
> character access, not to lazy IO.
>
> In C, this would be a comparison between  read  and  getchar . If I
> remember correctly, the former is faster for copying a file simply
> because copying one character at a time with  getchar  is too granular
> (you have to make an expensive system call every time). Of course, this
> reasoning only applies to C and not necessarily to Haskell.
>
> Do you have an example where you want chunking instead of single
> character access?
>

I am unable to think of any examples where you want chunking for any reason
other than efficiency.  Yesterday I spent some time on an element-wise
iteratee implementation, and unfortunately it's significantly slower than
any of the chunked implementations.  I'm certain there's room for
optimization, but I don't know if it's possible to make up the whole
difference.  I'd need to make some examination of the core to figure out
where it could be improved.

It's also possible that certain other implementations, such as your ProgramT
version or the simplified implementation John Millikin recently posted to
this list, would be more amenable to compiler magic for this purpose.

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100825/293fcb77/attachment.html


More information about the Haskell-Cafe mailing list