| 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 | # First 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 | # Create a temporary file for tests output |
| 30 | TMPFILE=$(mktemp) |
| 31 | |
| 32 | # Set trap to delete the temporary file on exit and call tap.sh '_exit' |
| 33 | trap 'rm -f "$TMPFILE"; _exit' EXIT |
| 34 | |
| 35 | # Set to number of active CPUS |
| 36 | NUM_CPUS="$(urcu_nproc)" |
| 37 | if [[ ${NUM_CPUS} -lt 4 ]]; then |
| 38 | NUM_CPUS=4 # Floor at 4 due to following assumptions. |
| 39 | fi |
| 40 | |
| 41 | # batch: 19 * 1 = 19 |
| 42 | # fraction: 15 * 29 = |
| 43 | # scalabilit NUM_CPUS * 15 |
| 44 | # reader 15 * 23 = |
| 45 | NUM_TESTS=$(( 19 + 435 + ( NUM_CPUS * 15 ) + 345 )) |
| 46 | |
| 47 | plan_tests ${NUM_TESTS} |
| 48 | |
| 49 | #run all tests |
| 50 | diag "Executing URCU tests" |
| 51 | |
| 52 | |
| 53 | #extra options, e.g. for setting affinity on even CPUs : |
| 54 | #EXTRA_OPTS=$(for a in $(seq 0 2 127); do echo -n "-a ${a} "; done) |
| 55 | |
| 56 | #ppc64 striding, use with NUM_CPUS=8 |
| 57 | |
| 58 | #stride 1 |
| 59 | #EXTRA_OPTS=$(for a in $(seq 0 2 15); do echo -n "-a ${a} "; done) |
| 60 | #stride 2 |
| 61 | #EXTRA_OPTS=$(for a in $(seq 0 4 31); do echo -n "-a ${a} "; done) |
| 62 | #stride 4 |
| 63 | #EXTRA_OPTS=$(for a in $(seq 0 8 63); do echo -n "-a ${a} "; done) |
| 64 | #stride 8 |
| 65 | #EXTRA_OPTS=$(for a in $(seq 0 16 127); do echo -n "-a ${a} "; done) |
| 66 | |
| 67 | #Vary update fraction |
| 68 | #x: vary update fraction from 0 to 0.0001 |
| 69 | #fix number of readers and reader C.S. length, vary delay between updates |
| 70 | #y: ops/s |
| 71 | EXTRA_OPTS="" |
| 72 | |
| 73 | |
| 74 | diag "Executing batch RCU test" |
| 75 | |
| 76 | BATCH_ARRAY="1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 |
| 77 | 131072 262144" |
| 78 | BATCH_TEST_ARRAY="test_urcu_gc" |
| 79 | |
| 80 | NR_WRITERS=$((NUM_CPUS / 2)) |
| 81 | NR_READERS=$((NUM_CPUS - NR_WRITERS)) |
| 82 | |
| 83 | for BATCH_SIZE in ${BATCH_ARRAY}; do |
| 84 | for TEST in ${BATCH_TEST_ARRAY}; do |
| 85 | okx ${URCU_TESTS_TIME_BIN} "${URCU_TESTS_BUILDDIR}/benchmark/${TEST}" "${NR_READERS}" "${NR_WRITERS}" "${DURATION}" \ |
| 86 | -d 0 -b "${BATCH_SIZE}" ${EXTRA_OPTS} 2>"${TMPFILE}" |
| 87 | while read -r line; do |
| 88 | echo "## $line" |
| 89 | done <"${TMPFILE}" |
| 90 | done |
| 91 | done |
| 92 | |
| 93 | TEST_ARRAY="test_urcu_gc test_urcu_signal_gc test_urcu_mb_gc test_urcu_qsbr_gc |
| 94 | test_urcu_lgc test_urcu_signal_lgc test_urcu_mb_lgc test_urcu_qsbr_lgc |
| 95 | test_urcu test_urcu_signal test_urcu_mb test_urcu_qsbr |
| 96 | test_rwlock test_perthreadlock test_mutex" |
| 97 | |
| 98 | #setting gc each 32768. ** UPDATE FOR YOUR ARCHITECTURE BASED ON TEST ABOVE ** |
| 99 | EXTRA_OPTS="${EXTRA_OPTS} -b 32768" |
| 100 | |
| 101 | diag "Executing update fraction test" |
| 102 | |
| 103 | WDELAY_ARRAY="0 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 |
| 104 | 65536 131072 262144 524288 1048576 2097152 4194304 8388608 |
| 105 | 16777216 33554432 67108864 134217728" |
| 106 | NR_WRITERS=$((NUM_CPUS / 2)) |
| 107 | NR_READERS=$((NUM_CPUS - NR_WRITERS)) |
| 108 | |
| 109 | for WDELAY in ${WDELAY_ARRAY}; do |
| 110 | for TEST in ${TEST_ARRAY}; do |
| 111 | okx ${URCU_TESTS_TIME_BIN} "${URCU_TESTS_BUILDDIR}/benchmark/${TEST}" "${NR_READERS}" "${NR_WRITERS}" "${DURATION}" \ |
| 112 | -d "${WDELAY}" ${EXTRA_OPTS} 2>"${TMPFILE}" |
| 113 | while read -r line; do |
| 114 | echo "## $line" |
| 115 | done <"${TMPFILE}" |
| 116 | done |
| 117 | done |
| 118 | |
| 119 | #Test scalability : |
| 120 | # x: vary number of readers from 0 to num cpus |
| 121 | # y: ops/s |
| 122 | # 0 writer. |
| 123 | |
| 124 | diag "Executing scalability test" |
| 125 | |
| 126 | NR_WRITERS=0 |
| 127 | |
| 128 | for NR_READERS in $(urcu_xseq 1 ${NUM_CPUS}); do |
| 129 | for TEST in ${TEST_ARRAY}; do |
| 130 | okx ${URCU_TESTS_TIME_BIN} "${URCU_TESTS_BUILDDIR}/benchmark/${TEST}" "${NR_READERS}" "${NR_WRITERS}" "${DURATION}" \ |
| 131 | ${EXTRA_OPTS} 2>"${TMPFILE}" |
| 132 | while read -r line; do |
| 133 | echo "## $line" |
| 134 | done <"${TMPFILE}" |
| 135 | done |
| 136 | done |
| 137 | |
| 138 | |
| 139 | # x: Vary reader C.S. length from 0 to 100 us |
| 140 | # y: ops/s |
| 141 | # 8 readers |
| 142 | # 0 writers |
| 143 | |
| 144 | diag "Executing reader C.S. length test" |
| 145 | |
| 146 | NR_READERS=${NUM_CPUS} |
| 147 | NR_WRITERS=0 |
| 148 | #in loops. |
| 149 | READERCSLEN_ARRAY="0 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152" |
| 150 | |
| 151 | for READERCSLEN in ${READERCSLEN_ARRAY}; do |
| 152 | for TEST in ${TEST_ARRAY}; do |
| 153 | okx ${URCU_TESTS_TIME_BIN} "${URCU_TESTS_BUILDDIR}/benchmark/${TEST}" "${NR_READERS}" "${NR_WRITERS}" "${DURATION}" \ |
| 154 | -c "${READERCSLEN}" ${EXTRA_OPTS} 2>"${TMPFILE}" |
| 155 | while read -r line; do |
| 156 | echo "## $line" |
| 157 | done <"${TMPFILE}" |
| 158 | done |
| 159 | done |