| 1 | #!/bin/bash |
| 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 | |
| 20 | |
| 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 | |
| 29 | NUM_TESTS=17 |
| 30 | |
| 31 | plan_tests ${NUM_TESTS} |
| 32 | |
| 33 | diag "Executing Hash table test" |
| 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 | |
| 40 | TESTPROG="${URCU_TESTS_BUILDDIR}/benchmark/test_urcu_hash" |
| 41 | |
| 42 | #thread multiplier: number of processors divided by 4. |
| 43 | NUM_CPUS="$(urcu_nproc)" |
| 44 | if [[ ${NUM_CPUS} -lt 4 ]]; then |
| 45 | NUM_CPUS=4 # Floor at 4 due to following assumptions. |
| 46 | fi |
| 47 | |
| 48 | THREAD_MUL=$((NUM_CPUS / 4)) |
| 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 |
| 56 | okx "${TESTPROG}" 0 $((4*THREAD_MUL)) "${DURATION}" -A -s -M 1 -N 1 -O 1 ${EXTRA_PARAMS} |
| 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 |
| 60 | okx "${TESTPROG}" 0 $((4*THREAD_MUL)) "${DURATION}" -A -u -M 1 -N 1 -O 1 ${EXTRA_PARAMS} |
| 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 |
| 64 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -s -M 1 -N 1 -O 1 ${EXTRA_PARAMS} |
| 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 |
| 68 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -M 1 -N 1 -O 1 ${EXTRA_PARAMS} |
| 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 |
| 76 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A ${EXTRA_PARAMS} |
| 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 |
| 81 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -s ${EXTRA_PARAMS} |
| 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 |
| 86 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -u ${EXTRA_PARAMS} |
| 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" |
| 95 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -m 1 -n 1048576 -i \ |
| 96 | -M 100000000 -N 100000000 -O 100000000 -B order ${EXTRA_PARAMS} |
| 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" |
| 102 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -m 1 -n 1048576 -i \ |
| 103 | -M 100000000 -N 100000000 -O 100000000 -B chunk ${EXTRA_PARAMS} |
| 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" |
| 109 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A -m 1 -n 1048576 -i \ |
| 110 | -M 100000000 -N 100000000 -O 100000000 -B mmap ${EXTRA_PARAMS} |
| 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 |
| 121 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
| 122 | -R 1000000 ${EXTRA_PARAMS} |
| 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 |
| 129 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
| 130 | -M 10 -N 10 -O 10 ${EXTRA_PARAMS} |
| 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 |
| 135 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
| 136 | -M 10 -N 10 -O 10 -u ${EXTRA_PARAMS} |
| 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 |
| 141 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
| 142 | -M 10 -N 10 -O 10 -s ${EXTRA_PARAMS} |
| 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 |
| 153 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
| 154 | -M 10 -N 10 -O 10 -R 0 -T 0 -S 10 -k 10 -s ${EXTRA_PARAMS} |
| 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 |
| 162 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
| 163 | -U ${EXTRA_PARAMS} |
| 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 |
| 169 | okx "${TESTPROG}" $((2*THREAD_MUL)) $((2*THREAD_MUL)) "${DURATION}" -A \ |
| 170 | -U -C 4 ${EXTRA_PARAMS} |