[Haskell-cafe] Slow IO
Bulat Ziganshin
bulat.ziganshin at gmail.com
Wed Sep 13 05:30:35 EDT 2006
Hello Ketil,
Wednesday, September 13, 2006, 10:41:13 AM, you wrote:
> But a String is something like 8 or 12 bytes per character, a
> ByteString gets you down to 1.
12-16. Char itself, pointer to the next list element, and two boxes
around them - this count for 16 bytes on 32-bit CPU. but cells with
small Char are preallocated at program startup, so it will be 12 bytes
for ascii-only strings
but that is not the whole story :) copying GC makes program's memory
usage 3 times larger, on average, than it really allocates while
compacting GC has only 2x overhead
ByteStrings are allocated in _unmovable_ part of GHC heap, so they
don't suffer from this problem. of course, it is not free -
program that creates and destroys large number of ByteStrings will
suffer from memory holes, which is right the problem solved by ghc's GC
so, for program that only allocates the difference may be 24/36 times
on average while for create-use-destroy-loop scenarios i can't make
any detailed prognoses
also, traversing those lengthy lists on GCs is very time-consuming
--
Best regards,
Bulat mailto:Bulat.Ziganshin at gmail.com
More information about the Haskell-Cafe
mailing list