[Haskell-cafe] Efficient way to break up a lazy bytestring
mutjida at gmail.com
Fri Dec 29 20:14:28 EST 2006
> breakUp s
> | L.null s = 
> | otherwise = h:(breakUp r) where
> (h,r) = L.splitAt 72 s
> Running this on the 2G file blows up the stack pretty quickly, taking
> the first 1 million records (there are 20M of them) with a big stack
> parameter gives about 25% productivity, with GC taking the other 75%.
> My understanding is that while this looks tail recursive, it isn't
> really because of laziness. I've tried throwing seq operators
> around, but they don't seem to do much to help the efficiency.
The function is not tail-recursive as written (you're returning
h:breakUp r) but that shouldn't be a problem because of lazy
Can you give more context, particularly what happens to the result of breakUp?
More information about the Haskell-Cafe