From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Mykyta Yatsenko" <mykyta.yatsenko5@gmail.com>,
<bpf@vger.kernel.org>, <andrii@kernel.org>,
<daniel@iogearbox.net>, <kernel-team@meta.com>,
<eddyz87@gmail.com>, <memxor@gmail.com>
Cc: "Mykyta Yatsenko" <yatsenko@meta.com>,
"Anton Protopopov" <a.s.protopopov@gmail.com>
Subject: Re: [PATCH bpf-next v2] bpf: Speed up htab lookups for u32/u64 keys
Date: Tue, 22 Sep 2026 01:40:30 +0000 [thread overview]
Message-ID: <DLLGNOQ59JIC.1O76G4NM0FXZ1@gmail.com> (raw)
In-Reply-To: <20260921-hashtab_fast_hashfn-v2-1-79aa962ec56b@meta.com>
On Mon, Sep 21, 2026 at 02:28 PM Mykyta Yatsenko <mykyta.yatsenko5@gmail.com> wrote:
> + /*
> + * Fold the jhash constant and key length into hashrnd once for the
> + * fixed-size fast paths instead of doing it on every lookup.
> + */
> + if (htab->map.key_size == sizeof(u32) ||
> + htab->map.key_size == sizeof(u64))
> + htab->hashrnd += JHASH_INITVAL + htab->map.key_size;
This optimization is probably not needed anymore?
> -static void *__htab_map_lookup_elem(struct bpf_map *map, void *key)
> +static __always_inline void *__htab_lookup(struct bpf_map *map, void *key, u32 key_size)
__htab_lookup() is __always_inline, but htab_map_hash() and
lookup_nulls_elem_raw() that consume key_size are not.
Whether memcmp() becomes a single compare in _u32/_u64 variants
is up to the compiler. Make both __always_inline?
next prev parent reply other threads:[~2026-09-22 1:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 21:28 [PATCH bpf-next v2] bpf: Speed up htab lookups for u32/u64 keys Mykyta Yatsenko
2026-09-21 21:38 ` Alexei Starovoitov
2026-09-21 22:34 ` bot+bpf-ci
2026-09-22 1:40 ` Alexei Starovoitov [this message]
2026-09-22 11:49 ` Mykyta Yatsenko
2026-09-22 7:31 ` Anton Protopopov
2026-09-22 11:45 ` Mykyta Yatsenko
2026-09-22 13:03 ` Anton Protopopov
2026-09-22 15:57 ` Mykyta Yatsenko
2026-09-22 16:19 ` Anton Protopopov
2026-09-22 16:29 ` Alexei Starovoitov
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=DLLGNOQ59JIC.1O76G4NM0FXZ1@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=a.s.protopopov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-team@meta.com \
--cc=memxor@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;
as well as URLs for NNTP newsgroup(s).