[erlang-questions] Strange optimization result
Anders Nygren
anders.nygren@REDACTED
Sun Oct 21 18:46:47 CEST 2007
On 10/21/07, Steve Vinoski <vinoski@REDACTED> wrote:
> On 21 Oct 2007 11:41:12 +0200, Bjorn Gustavsson <bjorn@REDACTED>
> wrote:
> > "Anders Nygren" <anders.nygren@REDACTED> writes:
> > >
> > > My only idea is that this is caused by some pathological CPU cache
> > > behaviour. Does anyone have a better explanation?
> >
> > Could be. I have another GUESS: using a tuple instead of dict will
> > result in a smaller heap size for the spawned process, which will lead
> > to more frequent garbage collections. You could use the spawn_opt()
> > BIF with the min_heap_size option.
> >
> > To get a similar heap size as when using a dict, use
> >
> > erts_debug:size(wfbm3:init()).
> >
> > which is 1120.
> >
>
> I didn't try this or Bob's suggestion of simulating a tuple, but I did
> eliminate a dict lookup in the code that finds shift values, and also
> changed the macros to use hard-coded string lengths (since the strings are
> fixed) rather than recalculating them with length/1, and got another 25%
> speedup:
>
> <http://steve.vinoski.net/blog/2007/10/21/faster-wf-still/>
>
>
So I then took Steve's latest and
- changed to using a tuple instead of dict and VICTORY :)
Steve's tbray16 on my laptop
real 0m10.929s
user 0m18.477s
sys 0m0.560s
With tuple instead of dict
real 0m14.126s
user 0m22.373s
sys 0m1.924s
- added [{min_heap_size, 3000}] to the spawn, as suggested by Bjorn
With tuple and min_heap_size, 1000
real 0m7.358s
user 0m11.725s
sys 0m0.480s
With tuple and min_heap_size, 2000
real 0m6.760s
user 0m10.957s
sys 0m0.388s
With tuple and min_heap_size, 3000
real 0m6.305s
user 0m10.149s
sys 0m0.380s
After that increasing the heap size does not make any difference.
So my next step will be to play with garbage collection and see what I can get.
/Anders
More information about the erlang-questions
mailing list