-
Notifications
You must be signed in to change notification settings - Fork 67
Closed
Description
I'm using the lazy interface of Data.Binary.Get to parse large binaries from disk, where most parts are skipped on the first pass. When using skip directly, I get a severe performance and space usage problem when the skipped byte count is large (many megabytes). I'm not an expert on lazy bytestring internals, but it seems like the input data is held on for too long before being skipped ("PINNED" memory usage in -hc heap profile). Using this wrapper around skip makes it several orders of magnitude faster and does not explode on the heap (I'm using GHC 7.10.1):
import qualified Data.Binary.Get as G
skipMany :: Int -> G.Get ()
skipMany bytes =
replicateM_ rep (G.skip cs) >> G.skip rest
where
cs = 1024
(rep, rest) = bytes `quotRem` cs
Metadata
Metadata
Assignees
Labels
No labels