Commit | Line | Data |
---|---|---|
ad460058 | 1 | #!/bin/bash |
de6cb9d5 MJ |
2 | # |
3 | # SPDX-License-Identifier: GPL-2.0-only | |
4 | # | |
5 | # SPDX-FileCopyrightText: 2022 EfficiOS Inc. | |
6 | # | |
7 | ||
8 | if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then | |
9 | UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh" | |
10 | else | |
11 | UTILSSH="$(dirname "$0")/../utils/utils.sh" | |
12 | fi | |
13 | ||
14 | # Enable TAP | |
15 | SH_TAP=1 | |
16 | ||
17 | # shellcheck source=../utils/utils.sh | |
18 | source "$UTILSSH" | |
19 | ||
ad460058 | 20 | |
748f9af1 MJ |
21 | # 1st parameter: seconds per test |
22 | DURATION=$1 | |
23 | ||
24 | if [ "x${DURATION}" = "x" ]; then | |
25 | echo "usage: $0 [DURATION]" | |
26 | exit 1 | |
27 | fi | |
28 | ||
ad460058 MD |
29 | NUM_TESTS=17 |
30 | ||
31 | plan_tests ${NUM_TESTS} | |
32 | ||
33 | diag "Executing Hash table test" | |
6d56bfa2 MD |
34 | |
35 | # TODO: missing tests: | |
36 | # - send kill signals during tests to change the behavior between | |
37 | # add/remove/random | |
38 | # - validate that "nr_leaked" is always 0 in SUMMARY for all tests | |
39 | ||
de6cb9d5 | 40 | TESTPROG="${URCU_TESTS_BUILDDIR}/benchmark/test_urcu_hash" |
fba91a85 | 41 | |
ad460058 | 42 | #thread multiplier: number of processors divided by 4. |
de6cb9d5 | 43 | NUM_CPUS="$(urcu_nproc)" |
ad460058 MD |
44 | if [[ ${NUM_CPUS} -lt 4 ]]; then |
45 | NUM_CPUS=4 # Floor at 4 due to following assumptions. | |
46 | fi | |
47 | ||
748f9af1 | 48 | THREAD_MUL=$((NUM_CPUS / 4)) |
6d56bfa2 MD |
49 | |
50 | EXTRA_PARAMS=-v | |
51 | ||
52 | # ** test update coherency with single-value table | |
53 | ||
54 | # rw test, single key, replace and del randomly, 4 threads, auto resize. | |
55 | # key range: init, lookup, and update: 0 to 0 | |
de6cb9d5 | 56 | okx "${TESTPROG}" 0 $((4*THREAD_MUL)) "${DURATION}" -A -s -M 1 -N 1 -O 1 ${EXTRA_PARAMS} |
6d56bfa2 MD |
57 | |
58 | # rw test, single key, add unique and del randomly, 4 threads, auto resize. | |
59 | # key range: init, lookup, and update: 0 to 0 | |
de6cb9d5 | 60 | okx "${TESTPROG}" 0 $((4*THREAD_MUL)) "${DURATION}" -A -u -M 1 -N 1 -O 1 ${EXTRA_PARAMS} |
6d56bfa2 MD |
61 | |
62 | # rw test, single key, replace and del randomly, 2 lookup threads, 2 update threads, auto resize. | |
63 | # key range: init, lookup, and update: 0 to 0 | |
de6cb9d5 | 64 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -s -M 1 -N 1 -O 1 ${EXTRA_PARAMS} |
6d56bfa2 MD |
65 | |
66 | # rw test, single key, add and del randomly, 2 lookup threads, 2 update threads, auto resize. | |
67 | # key range: init, lookup, and update: 0 to 0 | |
de6cb9d5 | 68 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -M 1 -N 1 -O 1 ${EXTRA_PARAMS} |
6d56bfa2 MD |
69 | |
70 | ||
71 | # ** test updates vs lookups with default table | |
72 | ||
73 | # rw test, 2 lookup, 2 update threads, add and del randomly, auto resize. | |
74 | # max 1048576 buckets | |
75 | # key range: init, lookup, and update: 0 to 999999 | |
de6cb9d5 | 76 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A ${EXTRA_PARAMS} |
6d56bfa2 MD |
77 | |
78 | # rw test, 2 lookup, 2 update threads, add_replace and del randomly, auto resize. | |
79 | # max 1048576 buckets | |
80 | # key range: init, lookup, and update: 0 to 999999 | |
de6cb9d5 | 81 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -s ${EXTRA_PARAMS} |
6d56bfa2 MD |
82 | |
83 | # rw test, 2 lookup, 2 update threads, add_unique and del randomly, auto resize. | |
84 | # max 1048576 buckets | |
85 | # key range: init, lookup, and update: 0 to 999999 | |
de6cb9d5 | 86 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -u ${EXTRA_PARAMS} |
6d56bfa2 MD |
87 | |
88 | ||
89 | # test memory management backends | |
90 | ||
91 | # rw test, 2 lookup, 2 update threads, add only, auto resize. | |
92 | # max buckets: 1048576 | |
93 | # key range: init, lookup, and update: 0 to 99999999 | |
94 | # mm backend: "order" | |
de6cb9d5 | 95 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -m 1 -n 1048576 -i \ |
ad460058 | 96 | -M 100000000 -N 100000000 -O 100000000 -B order ${EXTRA_PARAMS} |
6d56bfa2 MD |
97 | |
98 | # rw test, 2 lookup, 2 update threads, add only, auto resize. | |
99 | # max buckets: 1048576 | |
100 | # key range: init, lookup, and update: 0 to 99999999 | |
101 | # mm backend: "chunk" | |
de6cb9d5 | 102 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -m 1 -n 1048576 -i \ |
ad460058 | 103 | -M 100000000 -N 100000000 -O 100000000 -B chunk ${EXTRA_PARAMS} |
6d56bfa2 MD |
104 | |
105 | # rw test, 2 lookup, 2 update threads, add only, auto resize. | |
106 | # max buckets: 1048576 | |
107 | # key range: init, lookup, and update: 0 to 99999999 | |
108 | # mm backend: "mmap" | |
de6cb9d5 | 109 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -m 1 -n 1048576 -i \ |
ad460058 | 110 | -M 100000000 -N 100000000 -O 100000000 -B mmap ${EXTRA_PARAMS} |
6d56bfa2 MD |
111 | |
112 | ||
113 | # ** key range tests | |
114 | ||
115 | # rw test, 2 lookup, 2 update threads, add and del randomly, auto resize. | |
116 | # max 1048576 buckets | |
117 | # key range: init, and update: 0 to 999999 | |
118 | # key range: lookup: 1000000 to 1999999 | |
119 | # NOTE: reader threads in this test should never have a successful | |
120 | # lookup. TODO | |
de6cb9d5 | 121 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
ad460058 | 122 | -R 1000000 ${EXTRA_PARAMS} |
6d56bfa2 MD |
123 | |
124 | # ** small key range | |
125 | ||
126 | # rw test, 2 lookup, 2 update threads, add and del randomly, auto resize. | |
127 | # max 1048576 buckets | |
128 | # key range: init, update, and lookups: 0 to 9 | |
de6cb9d5 | 129 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
ad460058 | 130 | -M 10 -N 10 -O 10 ${EXTRA_PARAMS} |
6d56bfa2 MD |
131 | |
132 | # rw test, 2 lookup, 2 update threads, add_unique and del randomly, auto resize. | |
133 | # max 1048576 buckets | |
134 | # key range: init, update, and lookups: 0 to 9 | |
de6cb9d5 | 135 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
ad460058 | 136 | -M 10 -N 10 -O 10 -u ${EXTRA_PARAMS} |
6d56bfa2 MD |
137 | |
138 | # rw test, 2 lookup, 2 update threads, add_replace and del randomly, auto resize. | |
139 | # max 1048576 buckets | |
140 | # key range: init, update, and lookups: 0 to 9 | |
de6cb9d5 | 141 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
ad460058 | 142 | -M 10 -N 10 -O 10 -s ${EXTRA_PARAMS} |
6d56bfa2 MD |
143 | |
144 | # ** lookup for known keys | |
145 | ||
146 | # rw test, 2 lookup, 2 update threads, add_replace and del randomly, auto resize. | |
147 | # max 1048576 buckets | |
148 | # lookup range is entirely populated. | |
149 | # key range: init, and lookups: 0 to 9 | |
150 | # key range: updates: 10 to 19 | |
151 | # NOTE: reader threads in this test should always have successful | |
152 | # lookups. TODO | |
de6cb9d5 | 153 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
ad460058 | 154 | -M 10 -N 10 -O 10 -R 0 -T 0 -S 10 -k 10 -s ${EXTRA_PARAMS} |
6d56bfa2 MD |
155 | |
156 | # ** Uniqueness test | |
157 | ||
158 | # rw test, 2 lookup, 2 update threads, add_unique, add_replace and del randomly, auto resize. | |
159 | # max 1048576 buckets | |
160 | # asserts that no duplicates are observed by reader threads | |
161 | # standard length hash chains | |
de6cb9d5 | 162 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
ad460058 | 163 | -U ${EXTRA_PARAMS} |
6d56bfa2 MD |
164 | |
165 | # rw test, 2 lookup, 2 update threads, add_unique, add_replace and del randomly, auto resize. | |
166 | # max 1048576 buckets | |
167 | # asserts that no duplicates are observed by reader threads | |
168 | # create long hash chains: using modulo 4 on keys as hash | |
de6cb9d5 | 169 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
ad460058 | 170 | -U -C 4 ${EXTRA_PARAMS} |