Re: [Haskell-cafe] Space leak - help needed

2008-03-14 Thread Justin Bailey
On Thu, Mar 13, 2008 at 4:50 PM, Krzysztof Kościuszkiewicz <[EMAIL PROTECTED]> wrote: > Retainers are thunks or objects on stack that keep references to > live objects. All retainers of an object are called the object's > retainer set. Now when one makes a profiling run, say with ./jobname > +

Re: [Haskell-cafe] Space leak - help needed

2008-03-13 Thread Krzysztof Kościuszkiewicz
On Wed, Mar 12, 2008 at 12:34:38PM -0700, Justin Bailey wrote: > The stack blows up when a bunch of unevaluated thunks build up, and > you try to evaluate them. One way to determine where those thunks are > getting built is to use GHCs "retainer" profiling. Retainer sets will > show you the "call

Re: [Haskell-cafe] Space leak - help needed

2008-03-13 Thread Krzysztof Kościuszkiewicz
On Thu, Mar 13, 2008 at 05:52:05PM +0100, Bertram Felgenhauer wrote: > > ... Now evaluation of the parser state blows the stack... > > > > The code is at http://hpaste.org/6310 > > Apparently, stUpdate is too lazy. I'd define > > stUpdate' :: (s -> s) -> Parser s t () > stUpdate' f = st

Re: [Haskell-cafe] Space leak - help needed

2008-03-13 Thread Bertram Felgenhauer
Krzysztof Kościuszkiewicz wrote: > I have tried both Poly.StateLazy and Poly.State and they work quite well > - at least the space leak is eliminated. Now evaluation of the parser > state blows the stack... > > The code is at http://hpaste.org/6310 Apparently, stUpdate is too lazy. I'd define

Re: [Haskell-cafe] Space leak - help needed

2008-03-12 Thread Justin Bailey
On Wed, Mar 12, 2008 at 12:12 PM, Krzysztof Kościuszkiewicz <[EMAIL PROTECTED]> wrote: > I have tried both Poly.StateLazy and Poly.State and they work quite well > - at least the space leak is eliminated. Now evaluation of the parser > state blows the stack... > > The code is at http://hpaste.o

Re: [Haskell-cafe] Space leak - help needed

2008-03-12 Thread Krzysztof Kościuszkiewicz
On Mon, Mar 03, 2008 at 05:20:09AM +0100, Bertram Felgenhauer wrote: > > Another story from an (almost) happy Haskell user that finds himself > > overwhelmed by laziness/space leaks. > > > > I'm trying to parse a large file (>600MB) with a single S-expression > > like structure. With the help of

Re: [Haskell-cafe] Space leak - help needed

2008-03-02 Thread Bertram Felgenhauer
Krzysztof Kościuszkiewicz wrote: > Another story from an (almost) happy Haskell user that finds himself > overwhelmed by laziness/space leaks. > > I'm trying to parse a large file (>600MB) with a single S-expression > like structure. With the help of ByteStrings I'm down to 4min processing > time

Re: [Haskell-cafe] Space leak - help needed

2008-03-02 Thread Luke Palmer
On Mon, Mar 3, 2008 at 2:23 AM, Krzysztof Kościuszkiewicz <[EMAIL PROTECTED]> wrote: > Dear Haskellers, > > Another story from an (almost) happy Haskell user that finds himself > overwhelmed by laziness/space leaks. > > I'm trying to parse a large file (>600MB) with a single S-expression > like

[Haskell-cafe] Space leak - help needed

2008-03-02 Thread Krzysztof Kościuszkiewicz
Dear Haskellers, Another story from an (almost) happy Haskell user that finds himself overwhelmed by laziness/space leaks. I'm trying to parse a large file (>600MB) with a single S-expression like structure. With the help of ByteStrings I'm down to 4min processing time in constant space. However,

Re: [Haskell-cafe] Space Leak Help

2007-02-04 Thread kahl
> > > \begin{code} > > catWithLen :: [a] -> (Int -> [a]) -> [a] > > catWithLen xs f = h 0 xs > > where > > h k [] = f k > > h k (x : xs) = case succ k of-- forcing evaluation > > k' -> x : h k' xs > > \end{code} > > > > Thanks but this gives

Re: [Haskell-cafe] Space Leak Help

2007-02-04 Thread Stefan O'Rear
On Sun, Feb 04, 2007 at 09:45:12AM +, Dominic Steinitz wrote: > > pad :: Num a => [a] -> [a] > > pad = pad' 0 > > where pad' l [] | l `seq` False = undefined Stupid typo, that should be: where pad' l _ | l `seq` False = undefined > > pad' l [] = [0x80] ++ ps ++ lb > > w

Re: [Haskell-cafe] Space Leak Help

2007-02-04 Thread Dominic Steinitz
On Sunday 04 February 2007 08:28, Stefan O'Rear wrote: > On Sun, Feb 04, 2007 at 08:20:23AM +, Dominic Steinitz wrote: > > Someone suggested > > > > pad :: Num a => [a] -> [a] > > pad = pad' 0 > > where pad' !l [] = [0x80] ++ ps ++ lb > > where pl = (64-(l+9)) `mod` 64 > >

Re: [Haskell-cafe] Space Leak Help

2007-02-04 Thread Stefan O'Rear
On Sun, Feb 04, 2007 at 08:30:44AM +, Dominic Steinitz wrote: > On Saturday 03 February 2007 19:42, [EMAIL PROTECTED] wrote: > > I would try something along the following lines (untested): > > > > \begin{spec} > > catWithLen xs f = xs ++ f (length xs) > > \end{spec} > > > > \begin{code} > > cat

Re: [Haskell-cafe] Space Leak Help

2007-02-04 Thread Dominic Steinitz
On Saturday 03 February 2007 19:42, [EMAIL PROTECTED] wrote: > > I have re-written SHA1 so that is more idiomatically haskell and it is > > easy to see how it implements the specification. The only problem is I > > now have a space leak. I can see where the leak is but I'm less sure > > what to

Re: [Haskell-cafe] Space Leak Help

2007-02-04 Thread Stefan O'Rear
On Sun, Feb 04, 2007 at 08:20:23AM +, Dominic Steinitz wrote: > Someone suggested > > pad :: Num a => [a] -> [a] > pad = pad' 0 > where pad' !l [] = [0x80] ++ ps ++ lb > where pl = (64-(l+9)) `mod` 64 > ps = replicate pl 0x00 > lb = i2osp 8 (8*l) >

Re: [Haskell-cafe] Space Leak Help

2007-02-04 Thread Dominic Steinitz
On Saturday 03 February 2007 19:56, Pepe Iborra wrote: > pad :: [Word8] -> [Word8] > pad xs = pad' xs 0 > > pad' (x:xs) l = x : pad' xs (succ l) > pad' [] l = [0x80] ++ ps ++ lb >     where >        pl = (64-(l+9)) `mod` 64 >        ps = replicate pl 0x00 >        lb = i2osp 8 (8*l) Pepe, Thanks b

Re: [Haskell-cafe] Space Leak Help

2007-02-03 Thread Pepe Iborra
hi Dominic Explicit recursion works just fine for me and keeps things simple: pad :: [Word8] -> [Word8] pad xs = pad' xs 0 pad' (x:xs) l = x : pad' xs (succ l) pad' [] l = [0x80] ++ ps ++ lb where pl = (64-(l+9)) `mod` 64 ps = replicate pl 0x00 lb = i2osp 8 (8*l) at the c

Re: [Haskell-cafe] Space Leak Help

2007-02-03 Thread kahl
> > I have re-written SHA1 so that is more idiomatically haskell and it is easy > to > see how it implements the specification. The only problem is I now have a > space leak. I can see where the leak is but I'm less sure what to do about > getting rid of it. > > Here's the offending f

[Haskell-cafe] Space Leak Help

2007-02-03 Thread Dominic Steinitz
I have re-written SHA1 so that is more idiomatically haskell and it is easy to see how it implements the specification. The only problem is I now have a space leak. I can see where the leak is but I'm less sure what to do about getting rid of it. Here's the offending function: pad :: [Word8] -