public inbox for netfilter-devel@vger.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Aaryan Bansal <aaryan.bansal.dev@gmail.com>
Cc: kadlec@netfilter.org, netfilter-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hash: add fast paths for common key sizes and new fast hash functions
Date: Sun, 15 Mar 2026 09:20:15 +0100	[thread overview]
Message-ID: <abZrvwZYRTjCpFKj@strlen.de> (raw)
In-Reply-To: <20260315074432.444966-1-aaryan.bansal.dev@gmail.com>

Aaryan Bansal <aaryan.bansal.dev@gmail.com> wrote:
> Add optimized fast paths to jhash() and jhash2() for common key sizes
> (4, 8, 12 bytes) to bypass switch statement overhead. These fast paths
> use direct word reads instead of byte-by-byte processing.
> 
> Also add new specialized hash functions for integer keys:
> - jhash_int(): Fast hash for single 32-bit integers (~3x faster)
> - jhash_int_2words(): Fast hash for two 32-bit integers
> - jhash_int_3words(): Fast hash for three 32-bit integers (e.g., IPv3 tuples)
> - jhash_mix32(): Ultra-fast hash for single integers
> - jhash_mix32_fast(): Minimal hash for extreme speed
> 
> These are useful for in-kernel hash tables where maximum performance
> is critical and reduced hash quality is acceptable.
> 
> Measured speedup on typical workloads:
> - jhash 4-byte keys: ~1.1x
> - jhash 8-byte keys: ~1.4x
> - jhash 12-byte keys: ~1.4x
> - jhash_int for single integers: ~3x

I won't merge a patch that adds functionality with no users.

Also, there already are helpers that do this
(jhash_1word, jhash_2words, jhash_3words).

      reply	other threads:[~2026-03-15  8:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260311160904.192965-1-aaryan.bansal.dev@gmail.com>
2026-03-15  7:44 ` [PATCH] hash: add fast paths for common key sizes and new fast hash functions Aaryan Bansal
2026-03-15  8:20   ` Florian Westphal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=abZrvwZYRTjCpFKj@strlen.de \
    --to=fw@strlen.de \
    --cc=aaryan.bansal.dev@gmail.com \
    --cc=kadlec@netfilter.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox