I've been talking to Stephen Blackheath on the #haskell-in-depth channel, and he's just submitted another new program to the shootout. This entry is for the regex-dna problem.
For this benchmark, each language is limited by the speed of the regex library it's using.
Right... let me see. Here's what I did;
I am not certain, but it seems that forcing the evaluation of s1, s2 and s3 (the blobs of input data) before parallelizing the processing gave better CPU utilisation. I also changed the part at the end where it does large numbers of pattern substitutions, so that it updated everything in-place in a mutable buffer. I found that splitting the pattern substitutions into chunks sped things up by a factor of three. It looks like there's some sort of overhead incurred on large buffers when the regex 'match' function creates its AllMatches array.
The reason why I needed memmove instead of memcpy is that memmove can work on overlapping buffers.
These changes improved the performance from 1:00 user / 0:42.2 real to 0:40.1 user / 0:25.12 real on my dual core, compared with 23.3 sec user for the slower non-parallel one of the two C++ implementations. (The parallel one wouldn't build for me.)
You can see the details of the submission here, and the actual code. He also adds:
I took my unsafePerformIO's out too. I have a reputation to maintain!
It's good to see that someone else is working on making haskell look good (and doing a much better job than me thankfully!). Maybe soon we'll be topping the list, or at least beating Java to move up to 4th place.

Leave a comment