All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mykyta Yatsenko" <mykyta.yatsenko5@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v7 12/12] selftests/bpf: Add resizable hashmap to benchmarks
Date: Fri, 05 Jun 2026 12:03:23 +0000	[thread overview]
Message-ID: <20260605120323.DBE651F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260605-rhash-v7-12-5b8e05f8630d@meta.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The bpf-rhashmap-full-update benchmark measures the -E2BIG error path instead of successful map updates, invalidating the commit message's performance claims.
--

commit c016012bca8439800d9763b0e9dbdba68b4e1642
Author: Mykyta Yatsenko <yatsenko@meta.com>

selftests/bpf: Add resizable hashmap to benchmarks

This patch adds support for resizable hashmaps in BPF map benchmarks.
It claims a 5.25x speedup for rhtab over htab during full updates.

>     2. FULL UPDATE  (M events/sec per producer)
>     
>       htab  per-producer:
>         20.33   22.02   19.27   23.61   24.18   23.17   21.07
>         mean  21.94   range  19.27 - 24.18
>     
>       rhtab per-producer:
>        133.51  129.47   74.52  129.29  102.26  129.98  107.64
>         mean 115.24   range  74.52 - 133.51
>     
>       speedup (mean): 5.25x   (+425 %)
>     
>     In-place memcpy avoids the per-update alloc + RCU pointer swap
>     that htab pays.

[Severity: Medium]
Are these benchmark results measuring successful updates, or just the speed of
the -E2BIG error path?

In tools/testing/selftests/bpf/benchs/bench_bpf_hashmap_full_update.c:hashmap_full_update_setup(),
the userspace setup pre-fills the map to its maximum capacity:

    /* fill hash_map */
    map_fd = bpf_map__fd(ctx.skel->maps.hash_map_bench);
    max_entries = bpf_map__max_entries(ctx.skel->maps.hash_map_bench);
    for (i = 0; i < max_entries; i++)
        bpf_map_update_elem(map_fd, &i, &i, BPF_ANY);

The BPF program then attempts to insert a new key that doesn't exist in the map
in tools/testing/selftests/bpf/progs/bpf_hashmap_full_update_bench.c:benchmark():

    u32 cpu = bpf_get_smp_processor_id();
    u32 key = cpu + MAX_ENTRIES;
    ...
    bpf_loop(nr_loops, loop_update_callback, &key, 0);

Because the map is already full, does every update attempt immediately fail with
-E2BIG without performing any updates or memcpy?

For htab (which preallocates), returning -E2BIG requires a slow fallback
traversal of all other CPUs' empty freelists. For rhtab (no prealloc), it is
a fast atomic check against the element count.

Does this regression mean the benchmark is comparing the speed of error paths
rather than successful map updates, which might invalidate the performance
claims?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260605-rhash-v7-0-5b8e05f8630d@meta.com?part=12

  reply	other threads:[~2026-06-05 12:03 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05 11:41 [PATCH bpf-next v7 00/12] bpf: Introduce resizable hash map Mykyta Yatsenko
2026-06-05 11:41 ` [PATCH bpf-next v7 01/12] rhashtable: Add rhashtable_next_key() API Mykyta Yatsenko
2026-06-05 11:43   ` Herbert Xu
2026-06-05 11:41 ` [PATCH bpf-next v7 02/12] rhashtable: Add selftest for rhashtable_next_key() Mykyta Yatsenko
2026-06-05 11:43   ` Herbert Xu
2026-06-05 11:41 ` [PATCH bpf-next v7 03/12] rhashtable: Use irq work for shrinking Mykyta Yatsenko
2026-06-05 12:40   ` bot+bpf-ci
2026-06-05 11:41 ` [PATCH bpf-next v7 04/12] bpf: Implement resizable hashmap basic functions Mykyta Yatsenko
2026-06-05 11:41 ` [PATCH bpf-next v7 05/12] bpf: Implement iteration ops for resizable hashtab Mykyta Yatsenko
2026-06-05 11:56   ` sashiko-bot
2026-06-05 12:40   ` bot+bpf-ci
2026-06-05 11:41 ` [PATCH bpf-next v7 06/12] bpf: Allow special fields in " Mykyta Yatsenko
2026-06-05 11:41 ` [PATCH bpf-next v7 07/12] bpf: Optimize word-sized keys for resizable hashtable Mykyta Yatsenko
2026-06-05 11:54   ` sashiko-bot
2026-06-05 12:22   ` bot+bpf-ci
2026-06-05 11:41 ` [PATCH bpf-next v7 08/12] libbpf: Support " Mykyta Yatsenko
2026-06-05 11:41 ` [PATCH bpf-next v7 09/12] selftests/bpf: Add basic tests for resizable hash map Mykyta Yatsenko
2026-06-05 11:41 ` [PATCH bpf-next v7 10/12] selftests/bpf: Add BPF iterator " Mykyta Yatsenko
2026-06-05 11:56   ` sashiko-bot
2026-06-05 11:41 ` [PATCH bpf-next v7 11/12] bpftool: Add rhash map documentation Mykyta Yatsenko
2026-06-05 11:41 ` [PATCH bpf-next v7 12/12] selftests/bpf: Add resizable hashmap to benchmarks Mykyta Yatsenko
2026-06-05 12:03   ` sashiko-bot [this message]
2026-06-05 15:10 ` [PATCH bpf-next v7 00/12] bpf: Introduce resizable hash map patchwork-bot+netdevbpf

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=20260605120323.DBE651F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=mykyta.yatsenko5@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.