datapath: use CRC32 accelerated flow hash if available
authorFrancesco Fusco <ffusco@redhat.com>
Mon, 16 Dec 2013 09:22:43 +0000 (01:22 -0800)
committerJesse Gross <jesse@nicira.com>
Mon, 16 Dec 2013 20:36:26 +0000 (12:36 -0800)
commitdf9a0a8958192f6ed5f60ae61c0ca6dd7c20c6f5
tree72ec2bc9d3e6befc3d25c8bcebb79b53a49bb2ae
parent3c851001cbd55b080eaaa1c89ae033d8129cac28
datapath: use CRC32 accelerated flow hash if available

Currently OVS uses jhash2() for calculating flow hashes in its
internal flow_hash() function. The performance of the flow_hash()
function is critical, as the input data can be hundreds of bytes
long.

OVS is largely deployed in x86_64 based datacenters.  Therefore,
we argue that the performance critical fast path of OVS should
exploit underlying CPU features in order to reduce the per packet
processing costs. We replace jhash2 with the hash implementation
provided by the kernel hash lib, which exploits the crc32l
instruction to achieve high performance

Our patch greatly reduces the hash footprint from ~200 cycles of
jhash2() to around ~90 cycles in case of ovs_flow_hash_crc()
(measured with rdtsc over maximum length flow keys on an i7 Intel
CPU).

Additionally, we wrote a microbenchmark to stress the flow table
performance. The benchmark inserts random flows into the flow
hash and then performs lookups. Our hash deployed on a CRC32
capable CPU reduces the lookup for 1000 flows, 100 masks from
~10,100us to ~6,700us, for example.

Thus, simply use the newly introduced arch_fast_hash2() as a
drop-in replacement.

Signed-off-by: Francesco Fusco <ffusco@redhat.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
datapath/flow_table.c