From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Mykyta Yatsenko" <mykyta.yatsenko5@gmail.com>,
"Hao Peng" <flyingpenghao@gmail.com>
Cc: <andrii@kernel.org>, <bpf@vger.kernel.org>, <yatsenko@meta.com>
Subject: Re: [PATCH] bpf: Mix the seed into 8-byte resizable hashtab keys before folding
Date: Thu, 03 Dec 2026 04:03:52 +0000 [thread overview]
Message-ID: <DNASSOF0GVMD.AAPF3FCZ8AHQ@gmail.com> (raw)
In-Reply-To: <cd92450a-b149-425e-b4f6-397c1d0479e4@gmail.com>
On Tue, Dec 01, 2026 at 10:29 PM Mykyta Yatsenko <mykyta.yatsenko5@gmail.com> wrote:
> My results: jhash_2words() makes lookups with 8-byte keys slower:
> -35% at 1K and -74% to -77% at 1M.
That looks like the default keys of the bench, key[0] = i + 1.
On random keys Hao sees -10% to -22%. It's still a lot for this path.
> We can use another simple hash function to protect from equal halves
> hashing to same values, for example:
>
> static __always_inline u32 rhtab_hashfn_long(const void *data, u32 len, u32 seed)
> {
> u64 x = *(const unsigned long *)data ^ seed;
>
> return (x ^ (x >> 33)) * GOLDEN_RATIO_64 >> 32;
> }
Makes sense to me.
It fixes pointer keys too. Today 64 byte aligned pointers from one 4G
range use one bucket out of 64. They hit the same -EBUSY.
> Of course it does not protect from malicious uses.
That's ok.
Hao,
pls respin with this function and add its seq and rand numbers.
pw-bot: cr
prev parent reply other threads:[~2026-12-03 4:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 14:03 [PATCH] bpf: Mix the seed into 8-byte resizable hashtab keys before folding Peng Hao
2026-12-01 3:17 ` Alexei Starovoitov
2026-12-02 4:09 ` Hao Peng
2026-12-02 6:29 ` Mykyta Yatsenko
2026-12-03 4:03 ` Alexei Starovoitov [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=DNASSOF0GVMD.AAPF3FCZ8AHQ@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=flyingpenghao@gmail.com \
--cc=mykyta.yatsenko5@gmail.com \
--cc=yatsenko@meta.com \
/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