mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
f44bc543a0
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
45 lines
1.5 KiB
Bash
Executable file
45 lines
1.5 KiB
Bash
Executable file
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
source ./benchs/run_common.sh
|
|
|
|
set -eufo pipefail
|
|
|
|
header "Bloom filter map"
|
|
for v in 2 4 8 16 40; do
|
|
for t in 1 4 8 12 16; do
|
|
for h in {1..10}; do
|
|
subtitle "value_size: $v bytes, # threads: $t, # hashes: $h"
|
|
for e in 10000 50000 75000 100000 250000 500000 750000 1000000 2500000 5000000; do
|
|
printf "%'d entries -\n" $e
|
|
printf "\t"
|
|
summarize "Lookups, total operations: " \
|
|
"$($RUN_BENCH -p $t --nr_hash_funcs $h --nr_entries $e --value_size $v bloom-lookup)"
|
|
printf "\t"
|
|
summarize "Updates, total operations: " \
|
|
"$($RUN_BENCH -p $t --nr_hash_funcs $h --nr_entries $e --value_size $v bloom-update)"
|
|
printf "\t"
|
|
summarize_percentage "False positive rate: " \
|
|
"$($RUN_BENCH -p $t --nr_hash_funcs $h --nr_entries $e --value_size $v bloom-false-positive)"
|
|
done
|
|
printf "\n"
|
|
done
|
|
done
|
|
done
|
|
|
|
header "Hashmap without bloom filter vs. hashmap with bloom filter (throughput, 8 threads)"
|
|
for v in 2 4 8 16 40; do
|
|
for h in {1..10}; do
|
|
subtitle "value_size: $v, # hashes: $h"
|
|
for e in 10000 50000 75000 100000 250000 500000 750000 1000000 2500000 5000000; do
|
|
printf "%'d entries -\n" $e
|
|
printf "\t"
|
|
summarize_total "Hashmap without bloom filter: " \
|
|
"$($RUN_BENCH --nr_hash_funcs $h --nr_entries $e --value_size $v -p 8 hashmap-without-bloom)"
|
|
printf "\t"
|
|
summarize_total "Hashmap with bloom filter: " \
|
|
"$($RUN_BENCH --nr_hash_funcs $h --nr_entries $e --value_size $v -p 8 hashmap-with-bloom)"
|
|
done
|
|
printf "\n"
|
|
done
|
|
done
|