Skip to content

Commit 0408f68

Browse files
YifanYuan3meta-codesync[bot]
authored andcommitted
add erase code microbenchmark (#312)
Summary: Pull Request resolved: #312 This diff add Reed-solomon erase code to WDL. Since our own prod implementation is not open-source yet, we use the implementation from isa-l as a proxy for now. also contains a couple of other minor fixes. Reviewed By: charles-typ, mcfi Differential Revision: D87477309 fbshipit-source-id: c7e510af94a6d9546fb9181522954ef8fd111aad
1 parent b9c1c29 commit 0408f68

File tree

5 files changed

+54
-12
lines changed

5 files changed

+54
-12
lines changed

packages/wdl_bench/convert.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
parse_line.parse_line_xxhash_benchmark(f, sum_c)
3131
elif sys.argv[1] == "container_hash_maps_bench":
3232
parse_line.parse_line_container_hash_maps_bench(f, sum_c)
33+
elif sys.argv[1] == "erasure_code_perf":
34+
parse_line.parse_line_erasure_code_perf(f, sum_c)
3335
else:
3436
parse_line.parse_line(f, sum_c)
3537

packages/wdl_bench/install_wdl_bench.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ declare -A REPOS=(
1818
['libaegis']='https://github.com/aegis-aead/libaegis.git'
1919
['xxhash']='https://github.com/Cyan4973/xxHash.git'
2020
['glibc']='https://sourceware.org/git/glibc.git'
21+
['isa-l']='https://github.com/intel/isa-l.git'
2122
)
2223

2324
declare -A TAGS=(
@@ -29,6 +30,7 @@ declare -A TAGS=(
2930
['libaegis']='0.4.2'
3031
['xxhash']='136cc1f8fe4d5ea62a7c16c8424d4fa5158f6d68'
3132
['glibc']="glibc-${GLIBC_VERSION}"
33+
['isa-l']='d36de972efc18f2e85ca182a8b6758ecc7da512b'
3234
)
3335

3436
declare -A DATASETS=(
@@ -51,12 +53,12 @@ LINUX_DIST_ID="$(awk -F "=" '/^ID=/ {print $2}' /etc/os-release | tr -d '"')"
5153

5254
if [ "$LINUX_DIST_ID" = "ubuntu" ]; then
5355
apt install -y cmake autoconf automake flex bison \
54-
nasm clang patch git libssl-dev \
56+
nasm clang patch git libssl-dev libc6-dev\
5557
tar unzip perl openssl python3-dev gawk
5658

5759
elif [ "$LINUX_DIST_ID" = "centos" ]; then
5860
dnf install -y cmake autoconf automake flex bison \
59-
meson nasm clang patch \
61+
meson nasm clang patch glibc-static\
6062
git tar unzip perl openssl-devel python3-devel gawk
6163
fi
6264

@@ -71,7 +73,7 @@ fi
7173

7274
##################### BUILD AND INSTALL FUNCTIONS #########################
7375

74-
folly_benchmark_list="concurrency_concurrent_hash_map_bench hash_hash_benchmark container_hash_maps_bench stats_digest_builder_benchmark fibers_fibers_benchmark crypto_lt_hash_benchmark memcpy_benchmark memset_benchmark io_async_event_base_benchmark io_iobuf_benchmark function_benchmark random_benchmark synchronization_small_locks_benchmark synchronization_lifo_sem_bench range_find_benchmark"
76+
folly_benchmark_list="concurrency_concurrent_hash_map_bench hash_hash_benchmark container_hash_maps_bench stats_digest_builder_benchmark fibers_fibers_benchmark crypto_lt_hash_benchmark memcpy_benchmark memset_benchmark io_async_event_base_benchmark io_iobuf_benchmark function_benchmark random_benchmark synchronization_small_locks_benchmark synchronization_lifo_sem_bench range_find_benchmark hash_checksum_benchmark"
7577

7678
fbthrift_benchmark_list="ProtocolBench VarintUtilsBench"
7779

@@ -146,7 +148,7 @@ build_lzbench()
146148
pushd "${WDL_SOURCE}"
147149
clone $lib || echo "Failed to clone $lib"
148150
cd "$lib" || exit
149-
make -j
151+
make BUILD_STATIC=1 -j
150152
cp ./lzbench "${WDL_ROOT}/" || exit
151153

152154
download_dataset 'silesia'
@@ -235,6 +237,20 @@ build_glibc()
235237
popd || exit
236238
}
237239

240+
build_isa_l()
241+
{
242+
lib='isa-l'
243+
pushd "${WDL_SOURCE}"
244+
clone $lib || echo "Failed to clone $lib"
245+
cd "$lib" || exit
246+
./autogen.sh
247+
./configure
248+
make perfs -j
249+
cp ./erasure_code/erasure_code_perf "${WDL_ROOT}/" || exit
250+
251+
popd || exit
252+
}
253+
238254

239255
##################### BUILD AND INSTALL #########################
240256

@@ -248,6 +264,7 @@ build_vdso
248264
build_libaegis
249265
build_xxhash
250266
build_glibc
267+
build_isa_l
251268

252269
cp "${BPKGS_WDL_ROOT}/run.sh" ./
253270
cp "${BPKGS_WDL_ROOT}/run_prod.sh" ./

packages/wdl_bench/parse_line.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,12 @@ def parse_line_container_hash_maps_bench(f, sum_c):
190190
for k, v in data.items():
191191
if re.search("^(Find)|(Insert)|(InsertSqBr)|(Erase)|(Iter)", k):
192192
sum_c[k] = v
193+
194+
195+
def parse_line_erasure_code_perf(f, sum_c):
196+
for line in f:
197+
elements = line.split()
198+
if re.search("warm", elements[0]):
199+
name = elements[0]
200+
value = float(elements[-2])
201+
sum_c[name + ": MB/s"] = value

packages/wdl_bench/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ main() {
122122

123123
if [ "$run_type" = "prod" ]; then
124124
bash "${WDL_ROOT}/run_prod.sh"
125+
exit 0
125126
fi
126127

127128
set -u # Enable unbound variables check from here onwards

packages/wdl_bench/run_prod.sh

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,39 @@ Usage: ${0##*/} [-h] [--type single_core|all_core|multi_thread]
3030
EOF
3131
}
3232

33-
prod_benchmark_list_mem="memcpy_benchmark bench-memcmp"
33+
prod_benchmark_list_mem="memcpy_benchmark bench-memcmp memset_benchmark"
3434
prod_benchmark_list_hash="hash_hash_benchmark xxhash_benchmark"
3535
prod_benchmark_compression="lzbench"
3636
prod_benchmark_crypto="openssl libaegis_benchmark"
37-
prod_benchmark_checksum="hash_checksum_benchmark"
37+
prod_benchmark_checksum="hash_checksum_benchmark erasure_code_perf"
3838
prod_benchmark_rng="random_benchmark"
3939
prod_benchmark_chm="concurrency_concurrent_hash_map_bench"
4040
prod_benchmark_thrift="ProtocolBench VarintUtilsBench"
4141
prod_benchmark_f14="container_hash_maps_bench"
4242
prod_benchmark_lock="synchronization_small_locks_benchmark synchronization_lifo_sem_bench"
4343
prod_benchmark_vdso="vdso_bench"
4444

45-
prod_benchmarks="memcpy_benchmark bench-memcmp hash_hash_benchmark xxhash_benchmark lzbench openssl libaegis_benchmark hash_checksum_benchmark random_benchmark concurrency_concurrent_hash_map_bench ProtocolBench VarintUtilsBench container_hash_maps_bench synchronization_small_locks_benchmark synchronization_lifo_sem_bench vdso_bench"
45+
prod_benchmarks="memcpy_benchmark memset_benchmark bench-memcmp hash_hash_benchmark xxhash_benchmark lzbench openssl libaegis_benchmark hash_checksum_benchmark erasure_code_perf random_benchmark concurrency_concurrent_hash_map_bench ProtocolBench VarintUtilsBench container_hash_maps_bench synchronization_small_locks_benchmark synchronization_lifo_sem_bench vdso_bench"
4646

47-
benchmark_non_json_list=("openssl" "libaegis_benchmark" "lzbench" "vdso_bench" "xxhash_benchmark" "concurrency_concurrent_hash_map_bench" "container_hash_maps_bench")
47+
benchmark_non_json_list=("openssl" "libaegis_benchmark" "lzbench" "vdso_bench" "xxhash_benchmark" "concurrency_concurrent_hash_map_bench" "container_hash_maps_bench" "erasure_code_perf")
48+
49+
exec_non_json() {
50+
local input="$1"
51+
for item in "${benchmark_non_json_list[@]}"; do
52+
if [[ "$item" == "$input" ]]; then
53+
return 0
54+
fi
55+
done
56+
57+
return 1
58+
}
4859

4960
run_list=""
5061

5162
declare -A prod_benchmark_config=(
5263
['random_benchmark']="--bm_regex=xoshiro --json"
5364
['memcpy_benchmark']="--json"
65+
['memset_benchmark']="--json"
5466
['hash_hash_benchmark']="--bm_regex=RapidHash --json"
5567
['hash_checksum_benchmark']="--json"
5668
['synchronization_lifo_sem_bench']="--bm_min_iters=1000000 --json"
@@ -59,12 +71,13 @@ declare -A prod_benchmark_config=(
5971
['ProtocolBench']="--bm_regex=\"(^Binary)|(^Compact)Protocol\" --json"
6072
['VarintUtilsBench']=" --json"
6173
['concurrency_concurrent_hash_map_bench']=""
62-
['lzbench']="-v -ezstd1,3 ${WDL_DATASETS}/${dataset}"
74+
['lzbench']="-v -ezstd,1,3 ${WDL_DATASETS}/silesia.tar"
6375
['openssl']="speed -seconds 20 -evp aes-256-gcm"
6476
['vdso_bench']="-t 10 -p 20"
6577
['libaegis_benchmark']=""
6678
['xxhash_benchmark']="xxh3"
6779
['bench-memcmp']=""
80+
['erase_code_perf']=""
6881
)
6982

7083
main() {
@@ -123,12 +136,12 @@ main() {
123136
ldconfig
124137
fi
125138
out_file=""
126-
if [[ " $benchmark_non_json_list{[*]} " =~ " ${benchmark} " ]]; then
139+
if exec_non_json "${benchmark}"; then
127140
out_file="out_${benchmark}.txt"
128141
else
129142
out_file="out_${benchmark}.json"
130143
fi
131-
"./${benchmark}" "${prod_benchmark_config[$benchmark]}" 2>&1 | tee -a "${out_file}"
144+
bash -c "./${benchmark} ${prod_benchmark_config[$benchmark]}" 2>&1 | tee -a "${out_file}"
132145
if [ "$benchmark" = "openssl" ]; then
133146
unset LD_LIBRARY_PATH
134147
ldconfig
@@ -142,7 +155,7 @@ main() {
142155
fi
143156

144157
for benchmark in $run_list; do
145-
if [[ " $benchmark_non_json_list{[*]} " =~ " ${benchmark} " ]]; then
158+
if exec_non_json "${benchmark}"; then
146159
python3 ./convert.py "$benchmark"
147160
fi
148161
done

0 commit comments

Comments
 (0)