[Cake] an experiment with an alternate hasher

Dave Taht dave.taht at gmail.com
Sun Mar 26 12:00:34 EDT 2017


I am trying to see if I can get an adaquate avalanche distribution using
a hash of popcount(src),(popcount(dst),srcport,dstport, protocol, seed.

popcount is, regrettably, an sse4.2-only instruction, and this version
 of the assembly routine can actually popcount up to 8 ipv6 addresses
in a row, but you typically just pass it 2. I had a great deal of fun
writing this tho I haven't got around to actually seeing how good a
resulting hash would be!

The ipv4 version does both src and dst with a single popcnt.

The startup cost to further hash this is pretty insane - 30 cycles in
http://burtleburtle.net/bob/hash/spooky.html. Xor? CRC?

00000000004005a0 <popcount2asm>:
  4005a0:       31 c0                   xor    %eax,%eax
  4005a2:       89 f1                   mov    %esi,%ecx

00000000004005a4 <poploop7>:
  4005a4:       48 c1 e0 08             shl    $0x8,%rax
  4005a8:       f3 4c 0f b8 07          popcnt (%rdi),%r8
  4005ad:       48 83 c7 10             add    $0x10,%rdi
  4005b1:       4c 09 c0                or     %r8,%rax
  4005b4:       f3 4c 0f b8 47 f8       popcnt -0x8(%rdi),%r8
  4005ba:       4c 01 c0                add    %r8,%rax
  4005bd:       e2 e5                   loop   4005a4 <poploop7>
  4005bf:       c3                      retq


-- 
Dave Täht
Let's go make home routers and wifi faster! With better software!
http://blog.cerowrt.org


More information about the Cake mailing list