public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>, Martin Lau <kafai@meta.com>,
	Kernel Team <kernel-team@meta.com>, Eduard <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Mykyta Yatsenko <yatsenko@meta.com>,
	Anton Protopopov <a.s.protopopov@gmail.com>
Subject: Re: [PATCH RFC bpf-next v2 03/18] bpf: Implement lookup, delete, update for resizable hashtab
Date: Mon, 13 Apr 2026 20:43:27 +0100	[thread overview]
Message-ID: <06191c11-6342-40e2-8a3b-a3f32589e3a3@gmail.com> (raw)
In-Reply-To: <707a2aad-7617-49d9-8bdc-8f0ee22e7fe7@iogearbox.net>



On 4/13/26 5:27 PM, Daniel Borkmann wrote:
> On 4/13/26 6:24 PM, Alexei Starovoitov wrote:
>> On Mon, Apr 13, 2026 at 3:52 AM Mykyta Yatsenko
>> <mykyta.yatsenko5@gmail.com> wrote:
>>> On 4/13/26 12:10 AM, Alexei Starovoitov wrote:
>>>> On Wed, Apr 8, 2026 at 8:10 AM Mykyta Yatsenko
>>>> <mykyta.yatsenko5@gmail.com> wrote:
>>>>>
>>>>>
>>>>> +static void *rhtab_lookup_elem(struct bpf_map *map, void *key)
>>>>> +{
>>>>> +       struct bpf_rhtab *rhtab = container_of(map, struct 
>>>>> bpf_rhtab, map);
>>>>> +       /* Using constant zeroed params to force rhashtable use 
>>>>> inlined hashfunc */
>>>>> +       static const struct rhashtable_params params = { 0 };
>>>>> +
>>>>> +       return rhashtable_lookup_likely(&rhtab->ht, key, params);
>>>>
>>>> How does the asm look like?
>>>
>>> You can see how asm looks like below. An interesting thing is that gcc
>>> inlines jhash2, but not clang, which costs a lot of performance.
>>>
>>> gcc:
>>> lookup 20.675M ± 0.090M events/sec (approximated from 32 samples of 
>>> ~48ms)
>>>
>>> clang:
>>> cpu00: lookup 15.882M ± 0.530M events/sec (approximated from 32 samples
>>> of ~62ms)
>>>
>>> I think inlining is also consistent for htab and rhtab (either both
>>> inline or both do not inline).
>>
>> Try other hashes. I recall somebody from isovalent experimented
>> replacing jhash with xxhash and/or siphash in hash map and had nice
>> improvements for certain key sizes.
> 
> [ +Anton ]
> 
> page 26+: https://bpfconf.ebpf.io/bpfconf2023/bpfconf2023_material/ 
> anton-protopopov-lsf-mm-bpf-2023.pdf

Thanks for sharing that presentation, looking at the graphs on page 27, 
jhash2 is actually a better choice for the key size below 10 bytes 
(correct me if I'm wrong). And for rhashtable it's going to make even 
bigger difference, because jhash2 is inlined, because it's used by 
default by rhashtable, while other hash fns we'll have to provide via 
function pointer -> no inlining, which is a huge difference (see above).
Looking at the profiling data, hash fn (when inlined) does not look like 
a bottleneck memcmp is, though.
Anyways, I'll run benchmarks with other hash functions.

  reply	other threads:[~2026-04-13 19:43 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-08 15:10 [PATCH RFC bpf-next v2 00/18] bpf: Introduce resizable hash map Mykyta Yatsenko
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 01/18] bpf: Register rhash map Mykyta Yatsenko
2026-04-10 22:31   ` Emil Tsalapatis
2026-04-13  8:10     ` Mykyta Yatsenko
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 02/18] bpf: Add resizable hashtab skeleton Mykyta Yatsenko
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 03/18] bpf: Implement lookup, delete, update for resizable hashtab Mykyta Yatsenko
2026-04-12 23:10   ` Alexei Starovoitov
2026-04-13 10:52     ` Mykyta Yatsenko
2026-04-13 16:24       ` Alexei Starovoitov
2026-04-13 16:27         ` Daniel Borkmann
2026-04-13 19:43           ` Mykyta Yatsenko [this message]
2026-04-13 20:37   ` Emil Tsalapatis
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 04/18] rhashtable: Add rhashtable_walk_enter_from() Mykyta Yatsenko
2026-04-12 23:13   ` Alexei Starovoitov
2026-04-13 12:22     ` Mykyta Yatsenko
2026-04-13 22:22   ` Emil Tsalapatis
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 05/18] bpf: Implement get_next_key and free_internal_structs for resizable hashtab Mykyta Yatsenko
2026-04-13 22:44   ` Emil Tsalapatis
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 06/18] bpf: Implement bpf_each_rhash_elem() using walk API Mykyta Yatsenko
2026-04-13 23:02   ` Emil Tsalapatis
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 07/18] bpf: Implement batch ops for resizable hashtab Mykyta Yatsenko
2026-04-13 23:25   ` Emil Tsalapatis
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 08/18] bpf: Implement iterator APIs " Mykyta Yatsenko
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 09/18] bpf: Implement alloc and free " Mykyta Yatsenko
2026-04-12 23:15   ` Alexei Starovoitov
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 10/18] bpf: Allow timers, workqueues and task_work in " Mykyta Yatsenko
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 11/18] libbpf: Support resizable hashtable Mykyta Yatsenko
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 12/18] selftests/bpf: Add basic tests for resizable hash map Mykyta Yatsenko
2026-04-12 23:16   ` Alexei Starovoitov
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 13/18] selftests/bpf: Support resizable hashtab in test_maps Mykyta Yatsenko
2026-04-12 23:17   ` Alexei Starovoitov
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 14/18] selftests/bpf: Resizable hashtab BPF_F_LOCK tests Mykyta Yatsenko
2026-04-12 23:18   ` Alexei Starovoitov
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 15/18] selftests/bpf: Add stress tests for resizable hash get_next_key Mykyta Yatsenko
2026-04-12 23:19   ` Alexei Starovoitov
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 16/18] selftests/bpf: Add BPF iterator tests for resizable hash map Mykyta Yatsenko
2026-04-12 23:20   ` Alexei Starovoitov
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 17/18] bpftool: Add rhash map documentation Mykyta Yatsenko
2026-04-08 15:10 ` [PATCH RFC bpf-next v2 18/18] selftests/bpf: Add resizable hashmap to benchmarks Mykyta Yatsenko
2026-04-12 23:25   ` Alexei Starovoitov
2026-04-12 23:11 ` [PATCH RFC bpf-next v2 00/18] bpf: Introduce resizable hash map Alexei Starovoitov
2026-04-13  8:28   ` Mykyta Yatsenko

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=06191c11-6342-40e2-8a3b-a3f32589e3a3@gmail.com \
    --to=mykyta.yatsenko5@gmail.com \
    --cc=a.s.protopopov@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kafai@meta.com \
    --cc=kernel-team@meta.com \
    --cc=memxor@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