iteratee space leaks after a semantic change to enumPure1Chunk

John Lato jwlato at gmail.com
Thu Nov 3 12:10:35 GMT 2011


I've rolled back the patch and fixed Iteratee.zip and
Iteratee.enumWith so they work properly with the old enumPure1Chunk
behavior.  The new versions seem to be much faster in normal use cases
also.

I'll try to get an update on Hackage later today, but I need to do a
little cleanup first.

John

On Wed, Nov 2, 2011 at 6:48 PM, John Lato <jwlato at gmail.com> wrote:
> Hello,
>
> Apologies for the latency, my main box is in the shop for a warranty repair.
>
> In principle I agree with all your points that this should be reverted
> (`darcs rollback` is sufficient), however doing so now breaks
> Iteratee.zip.  It should be possible to fix this within Iteratee.zip,
> which I should have time to do tomorrow.
>
> On a related matter, does anyone have any suggestions for how to
> create testcases for things like memory usage of an executable, or
> non-termination (within a timeout interval)?
>
> John
>
> On Mon, Oct 31, 2011 at 8:15 AM, Akio Takano <tkn.akio at gmail.com> wrote:
>> Hi,
>>
>> The program below leaks space when compiled with iteratee-0.8.5.0 or later, but
>> it does not with 0.8.4.0
>>
>> import qualified Data.Iteratee as I
>>
>> main = I.enumList (replicate 10000000 [True, False]) (I.zip I.head I.last)
>>    >>= I.run >>= print
>>
>> This is due to a change introduced in 0.8.5.0. It is a change of the
>> semantics of
>> enumPure1Chunk, which is called by zip. It now pushes
>> data into an iteratee that is in the done state. Because I.head moves
>> to the done state
>> after consuming one element, the subsequent part of the stream is
>> pushed into it, leading
>> to a space leak.
>>
>> In addition to zip, enumWith suffers from the same problem.
>>
>> While the change to enumPure1Chunk is marked as a bugfix, i would
>> rather expect the old behavior
>> because it's more consistent with other enumerators. Most of the
>> enumerators in the library
>> does early termination, in the sense that it stops feeding data to an
>> iteratee as soon as it detects
>> that the interatee is in the done state. So I would expect
>> enumPure1Chunk to do the same.
>> I think it's ok to drop the stream when the iteratee is done, because
>> if the user doesn't want to
>> drop any information, they can always keep their iteratee in the cont
>> state until it sees EOF.
>>
>> Would it be a choice to change it back to the old one? I'm willing to
>> submit a patch in that case.
>>
>> Regards,
>> Takano Akio
>>
>> _______________________________________________
>> Iteratee mailing list
>> Iteratee at projects.haskell.org
>> http://projects.haskell.org/cgi-bin/mailman/listinfo/iteratee
>>
>



More information about the Iteratee mailing list