[erlang-questions] Strange optimization result
Sat Oct 20 16:08:41 CEST 2007
I am playing around with Tim Bray's widefinder problem.
Actually I am playing with Steve V's latest version
In it he is using a dict for Boyer-Moore searching, the dict is just
a map from char code to shift amount i.e. the keys are 1 - 255
and the values are ints.
I figured that it would be faster to just have a tuple with the shift values.
So I changed the code to generate a tuple instead of a dict. And the
lookups changed from
To my big surprise the program now runs slower.
On a file with 1M rows approx. 192 M.
Steve's original code, using dics, as reported by time
My modified, using a tuple
Interesting to note is the high value for sys in my version.
Also the tuple version does not manage to max out the CPU use
it peaks at ~85%, while the dict version gets 100% CPU load.
The program starts 64 erlang processes on my dual core laptop.
My only idea is that this is caused by some pathological CPU cache
behaviour. Does anyone have a better explanation?
More information about the erlang-questions