Re: [PATCH RFC bpf-next v2 18/18] selftests/bpf: Add resizable hashmap to benchmarks

Alexei Starovoitov
2026-04-12T23:25:54Z

On Wed, Apr 8, 2026 at 8:11 AM Mykyta Yatsenko
<mykyta.yatsenko5@gmail.com> wrote:
>
> From: Mykyta Yatsenko <yatsenko@meta.com>
>
> Support resizable hashmap in BPF map benchmarks.
>
> Results:
> $ sudo ./bench -w3 -d10 -a bpf-rhashmap-full-update
> 0:hash_map_full_perf 21641414 events per sec
>
> $ sudo ./bench -w3 -d10 -a bpf-hashmap-full-update
> 0:hash_map_full_perf 4392758 events per sec
>
> $ sudo ./bench -w3 -d10 -a -p8 htab-mem --use-case overwrite --value-size 8
> Iter 0 (302.834us): per-prod-op 62.85k/s, memory usage 2.70MiB
> Iter 1 (-44.810us): per-prod-op 62.81k/s, memory usage 2.70MiB
> Iter 2 (-45.821us): per-prod-op 62.81k/s, memory usage 2.70MiB
> Iter 3 (-63.658us): per-prod-op 62.92k/s, memory usage 2.70MiB
> Iter 4 ( 32.887us): per-prod-op 62.85k/s, memory usage 2.70MiB
> Iter 5 (-76.948us): per-prod-op 62.75k/s, memory usage 2.70MiB
> Iter 6 (157.235us): per-prod-op 63.01k/s, memory usage 2.70MiB
> Iter 7 (-118.761us): per-prod-op 62.85k/s, memory usage 2.70MiB
> Iter 8 (127.139us): per-prod-op 62.92k/s, memory usage 2.70MiB
> Iter 9 (-169.908us): per-prod-op 62.99k/s, memory usage 2.70MiB
> Iter 10 (101.962us): per-prod-op 62.97k/s, memory usage 2.70MiB
> Iter 11 (-64.330us): per-prod-op 63.05k/s, memory usage 2.70MiB
> Iter 12 (-20.543us): per-prod-op 62.86k/s, memory usage 2.70MiB
> Iter 13 ( 55.382us): per-prod-op 62.95k/s, memory usage 2.70MiB

No need to list them all. 2 or 3 is enough.

> Summary: per-prod-op 62.92 ± 0.09k/s, memory usage 2.70 ± 0.00MiB, peak memory usage 2.96MiB
>
> $ sudo ./bench -w3 -d10 -a -p8 rhtab-mem --use-case overwrite --value-size 8
> Iter 0 (316.805us): per-prod-op 96.40k/s, memory usage 2.71MiB
> Iter 1 (-35.225us): per-prod-op 96.54k/s, memory usage 2.71MiB
> Iter 2 (-12.431us): per-prod-op 96.54k/s, memory usage 2.71MiB
> Iter 3 (-56.537us): per-prod-op 96.58k/s, memory usage 2.71MiB
> Iter 4 ( 27.108us): per-prod-op 96.62k/s, memory usage 2.71MiB
> Iter 5 (-52.491us): per-prod-op 96.57k/s, memory usage 2.71MiB
> Iter 6 ( -2.777us): per-prod-op 96.52k/s, memory usage 2.71MiB
> Iter 7 (108.963us): per-prod-op 96.45k/s, memory usage 2.71MiB
> Iter 8 (-61.575us): per-prod-op 96.48k/s, memory usage 2.71MiB
> Iter 9 (-21.595us): per-prod-op 96.14k/s, memory usage 2.71MiB
> Iter 10 ( 3.243us): per-prod-op 96.36k/s, memory usage 2.71MiB
> Iter 11 ( 3.102us): per-prod-op 94.70k/s, memory usage 2.71MiB
> Iter 12 (109.102us): per-prod-op 95.77k/s, memory usage 2.71MiB
> Iter 13 ( 16.153us): per-prod-op 95.91k/s, memory usage 2.71MiB
> Summary: per-prod-op 96.19 ± 0.57k/s, memory usage 2.71 ± 0.00MiB, peak memory usage 2.71MiB
>
> sudo ./bench -w3 -d10 -a bpf-hashmap-lookup --key_size 4\
> --max_entries 1000 --nr_entries 500 --nr_loops 1000000
> cpu00: lookup 28.603M ± 0.536M events/sec (approximated from 32 samples of ~34ms)
>
> sudo ./bench -w3 -d10 -a bpf-rhashmap-lookup --key_size 4\
> --max_entries 1000 --nr_entries 500 --nr_loops 1000000
> cpu00: lookup 27.340M ± 0.864M events/sec (approximated from 32 samples of ~36ms)

What about other key sizes? That would be more useful info.
size 8 especially.

and different entries.
Think of holistic benchmark. Everything that one might need
from a hashtable.

key_size=4, 500 entries... is ... ok. fine. but not something
anyone can use to make a decision whether bpf_rhash should be
used or not by a user with its own use case pattern.