bpf/benchs: Add benchmarks for comparing hashmap lookups w/ vs. w/out bloom filter
authorJoanne Koong <joannekoong@fb.com>
Wed, 27 Oct 2021 23:45:04 +0000 (16:45 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 28 Oct 2021 20:22:49 +0000 (13:22 -0700)
commitf44bc543a079c2ebc534cbfabd6fbfcfc2b09f72
tree829ff328e26b552bd254d7b3b77ce0067e85f678
parent57fd1c63c9a687c5fdc86fa628c490d6733e8d0b
bpf/benchs: Add benchmarks for comparing hashmap lookups w/ vs. w/out bloom filter

This patch adds benchmark tests for comparing the performance of hashmap
lookups without the bloom filter vs. hashmap lookups with the bloom filter.

Checking the bloom filter first for whether the element exists should
overall enable a higher throughput for hashmap lookups, since if the
element does not exist in the bloom filter, we can avoid a costly lookup in
the hashmap.

On average, using 5 hash functions in the bloom filter tended to perform
the best across the widest range of different entry sizes. The benchmark
results using 5 hash functions (running on 8 threads on a machine with one
numa node, and taking the average of 3 runs) were roughly as follows:

value_size = 4 bytes -
10k entries: 30% faster
50k entries: 40% faster
100k entries: 40% faster
500k entres: 70% faster
1 million entries: 90% faster
5 million entries: 140% faster

value_size = 8 bytes -
10k entries: 30% faster
50k entries: 40% faster
100k entries: 50% faster
500k entres: 80% faster
1 million entries: 100% faster
5 million entries: 150% faster

value_size = 16 bytes -
10k entries: 20% faster
50k entries: 30% faster
100k entries: 35% faster
500k entres: 65% faster
1 million entries: 85% faster
5 million entries: 110% faster

value_size = 40 bytes -
10k entries: 5% faster
50k entries: 15% faster
100k entries: 20% faster
500k entres: 65% faster
1 million entries: 75% faster
5 million entries: 120% faster

Signed-off-by: Joanne Koong <joannekoong@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211027234504.30744-6-joannekoong@fb.com
tools/testing/selftests/bpf/bench.c
tools/testing/selftests/bpf/benchs/bench_bloom_filter_map.c
tools/testing/selftests/bpf/benchs/run_bench_bloom_filter_map.sh
tools/testing/selftests/bpf/benchs/run_common.sh