Daniel Fischer ha scritto:
Am Dienstag, 3. März 2009 15:35 schrieb Manlio Perillo:
Claus Reinke ha scritto:
At first guess it sounds like you're holding onto too much, if not the
whole stream perhaps bits within each chunk.
It is possible.

I split the string in lines, then map some functions on each line to
parse the data, and finally calling toU, for converting to an UArr.
Just to make sure (code fragments or, better, reduced examples
would make it easier to see what the discussion is about): are you
forcing the UArr to be constructed before putting it into the Map?
parse handle =
   contents <- S.hGetContents handle
   let v =  map singleton' $ ratings contents
   let m = foldl1' (unionWith appendU) v
   v `seq` return $! m

The (v `seq` ) is completely useless.
Maybe (size m) `seq` return m
would help?


In one of my tests I did:

  rnf v `seq` rnf m `seq` return m

Memory usage was the same


-- XXX these are missing from uvector package
instance (NFData a, NFData b) => NFData (a :*: b) where
    -- NOTE: (:*:) is already strict
    rnf (a :*: b) = a `seq` b `seq` ()

instance NFData a => NFData (UArr a) where
    -- NOTE: UArr is already strict
    rnf array = array `seq` ()


Regards  Manlio
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to