[PATCH v5 0/7] Cuckoo hash optimization for small key sizes

Stephen Hemminger
2026-01-30T20:23:34Z

This series improves the hash library's key comparison performance
and portability. The main goals are:

- Hide internal implementation details to prevent future ABI breakage
- Enable optimized key comparisons on all architectures (not just
x86 and ARM64)
- Add specialized compare functions for common small key sizes
(2-20 bytes) to avoid memcmp overhead
- Improve test coverage and code quality

Changes in v5:
- Rebase onto latest main
- New patch: remove spurious warnings in CRC32 algorithm selection
that fired even when the requested algorithm was successfully used
- Improved commit message for patch 4 (was patch 3)
- New patch: convert hash unit tests to use test suite runner
framework for structured output with per-test pass/fail status
- New patch: add dedicated test for key compare functions that
exercises all sizes in cmp_jump_table
- Use table lookup instead of switch statement for key size selection
- Add static_assert to verify table consistency
- Fix minor return value issues in small key compare functions

Changes in v4:
- Add test for more key sizes
- Add a few more special case sizes

Stephen Hemminger (7):
hash: move table of hash compare functions out of header
hash: use static_assert
hash: remove spurious warnings in CRC32 init
hash: simplify key comparison across architectures
hash: add support for common small key sizes
app/test: convert hash test to use test suite runner
test/hash: add test for key compare functions

app/test/test_hash.c | 249 +++++++++++++++++++++---------
lib/hash/rte_cmp_arm64.h | 62 +-------
lib/hash/rte_cmp_generic.h | 35 +++++
lib/hash/rte_cmp_x86.h | 62 +-------
lib/hash/rte_cuckoo_hash.c | 301 ++++++++++++++++++++++++++++++++-----
lib/hash/rte_cuckoo_hash.h | 84 +----------
lib/hash/rte_hash_crc.c | 8 +-
7 files changed, 490 insertions(+), 311 deletions(-)
create mode 100644 lib/hash/rte_cmp_generic.h

--
2.51.0