2008/5/20 Andrew Coppin <andrewcoppin at btinternet.com>:
> Ah, so *that's* what bang patterns do?
Exactly. If you have a pattern (even a simple one like 'n'), and you
prefix it with a bang (!), the function will force its evaluation.
>> 2) make_block_bs is sub-optimal, and very critical to performance.
>> Yeah, so I see. (60% time spent here... ouch!) I'll bet that's where C is
> beating me...
Maybe that's a bit optimistic, but it's a start :).
>>> I decided to use Data.Binary for it
>> I'm not familiar with that library (i.e. what it does or how you use it).
It's a library to serialize / deserialize haskell values. It uses
ByteStrings, and it's very fast. I suggest to take a look at it (it's
on Hackage).
> I did try that, but it didn't seem to make any difference for me. [Maybe it
> does now because of your other improvements? Which version of GHC and which
> platform are you running on? I'm GHC 6.8.2 on Windows...]
If you recompiled the executable correctly, maybe you were doing
profiling? Profiling slows some simple operations so much, that the
benefits of a low-level optimization like this can be lost.
Salvatore