
Thanks for the tips, some comments:
a) I tried to print the list before my expensive map (prints fast) and
even copy-paste the content into the source code, but it did not help.
b) What do you mean by this?
One more question: when I run my program with -s, the stats:
4,961,037,352 bytes allocated in the heap
19,431,024 bytes copied during GC
[...]
3 MB total memory in use (0 MB lost due to fragmentation)
What does the first number (~ 5G memory) mean? When I wrote my
functions, I just assumed that even the bad code will be fast enough.
(Even this question is more about learning that a practical issue.)
Can you recommend any docs about this kind of Haskell internals?
PS: splitting the input file to two, and use bash to wait both half
reduces the runtime by ~40%. What I want here is to annotate my
program with this knowledge to help ghc to beat bash :)
On 6/5/15, Marcin Mrotek
My first guesses would be that: a) Your program is slowed down because lines from the file is read one line by one, i.e. there's lazy IO at work. Have you tried your code on a list that's loaded in the memory as a whole at once? b) The cost of dereferencing the next link in a list overwhelms the cost of computing one answer. Have you tried using a tree instead?
Best regards, Marcin Mrotek