Choosing better HASH_BIAS

  • From: Юрий Соколов <funny.falcon@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 6 Sep 2013 19:54:08 +0400

Hello,

Benching one of homegrown software it were discovered, that it spends
measurable amount of time in lua_obj_equal cause of calling to ffi.gc .
(linux x86_64)

It looks like setting HASH_BIAS to 0 gives less collisions in finalizers
table.

Testing script: http://pastebin.com/6vzisjBa

Results:

With current HASH_BIAS:

$ time luajit test_gc.lua 10000000
10000000

real    0m5.735s
user    0m5.496s
sys     0m0.232s

With HASH_BIAS (0x0):

$ time luajit test_gc.lua 10000000
10000000

real    0m4.800s
user    0m4.532s
sys     0m0.264s

Perhaps, more adequate value for HASH_BIAS exists (for example, 0x10100000
is good for some patterns),
but current value is definitely bad.

With regards,
Sokolov Yura aka funny_falcon

Other related posts: