erlang:phash2(now())

eF mich569 at gmail.com
Mon Oct 4 06:54:54 EDT 2010


forget deleting refs, I confused it with another project.

On 4 October 2010 11:17, Lev Walkin <vlm at lionet.info> wrote:

>
> In some of my tests there were improvements in the order of single digit
> percentages. That's a good enough for me to get rid of phashing now(). Don't
> forget about GC implications of getting now() in and out.
>
> What do you mean you could delete refs? I believe refs are not better than
>
> On Oct 4, 2010, at 1:44 AM, eF wrote:
>
> I forked riak from github some time ago substitute erlang:phash2 with
> make_ref. I did not reveal any significant performance jump ;)
>
> However I agree with you that make_ref just looks better and seems to be
> more accurate. Actually, no hash is needed (at least in riak_client) because
> it is used to match on specific messages (to not mix map/reds etc.) and we
> can easily match on make_ref which is as good as any erlang term.
>
> My initial motivation was better control over memory (i.e. I could delete
> refs), but there was no improvement also, so I gave up the idea.
>
>
> Michal Zajda
>
> On 2 October 2010 16:00, Lev Walkin <vlm at lionet.info> wrote:
>
>>
>> In riak sources there are many references to erlang:phash2(erlang:now()).
>>
>> Why not use idiomatic make_ref() or at the very least
>> erlang:phash2(make_ref()), which is faster?
>>
>> 1> perftest:comprehensive(100000, fun() -> erlang:phash2(erlang:now())
>> end).
>> Sequential 100000 cycles in ~1 seconds (193510 cycles/s)
>> Parallel 2 100000 cycles in ~1 seconds (187282 cycles/s)
>> Parallel 4 100000 cycles in ~1 seconds (197310 cycles/s)
>> Parallel 10 100000 cycles in ~1 seconds (182890 cycles/s)
>> Parallel 100 100000 cycles in ~0 seconds (208671 cycles/s)
>> [197310,182890,208671]
>> 2> perftest:comprehensive(100000, fun() -> erlang:phash2(make_ref()) end).
>> Sequential 100000 cycles in ~0 seconds (323952 cycles/s)
>> Parallel 2 100000 cycles in ~0 seconds (301875 cycles/s)
>> Parallel 4 100000 cycles in ~0 seconds (308568 cycles/s)
>> Parallel 10 100000 cycles in ~0 seconds (287875 cycles/s)
>> Parallel 100 100000 cycles in ~0 seconds (326416 cycles/s)
>> [308568,287875,326416]
>> 3> perftest:comprehensive(100000, fun() -> make_ref() end).
>> Sequential 100000 cycles in ~0 seconds (1299765 cycles/s)
>> Parallel 2 100000 cycles in ~0 seconds (934492 cycles/s)
>> Parallel 4 100000 cycles in ~0 seconds (1111679 cycles/s)
>> Parallel 10 100000 cycles in ~0 seconds (1241434 cycles/s)
>> Parallel 100 100000 cycles in ~0 seconds (1264350 cycles/s)
>> [1111679,1241434,1264350]
>> 4>
>>
>> make_ref is 6 times faster than erlang:phash2(make_ref()) which is 50%
>> faster than erlang:phash2(now()).
>>
>> Of course, in the grand scheme of things this might not be your biggest
>> bottleneck, but why hashing now() when there exsists an idiomatic make_ref()
>> solution? Am I missing something?
>>
>> --
>> Lev Walkin
>> vlm at lionet.info
>>
>> _______________________________________________
>> riak-users mailing list
>> riak-users at lists.basho.com
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>>
>
>
>   --
> vlm
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20101004/49d1c170/attachment.html>


More information about the riak-users mailing list