[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 40/41] tests/qht-bench: Adjust testing rate by -1
From: |
Alex Bennée |
Subject: |
[PULL 40/41] tests/qht-bench: Adjust testing rate by -1 |
Date: |
Tue, 7 Jul 2020 08:08:57 +0100 |
From: Richard Henderson <richard.henderson@linaro.org>
Since the seed must be non-zero, subtracting 1 means puts the
rate in 0..UINT64_MAX-1, which allows the 0 and UINT64_MAX
thresholds to corrspond to 0% (never) and 100% (always).
Suggested-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200626200950.1015121-2-richard.henderson@linaro.org>
diff --git a/tests/qht-bench.c b/tests/qht-bench.c
index eb88a9013761..ad885d89d054 100644
--- a/tests/qht-bench.c
+++ b/tests/qht-bench.c
@@ -25,7 +25,13 @@ struct thread_stats {
struct thread_info {
void (*func)(struct thread_info *);
struct thread_stats stats;
- uint64_t r;
+ /*
+ * Seed is in the range [1..UINT64_MAX], because the RNG requires
+ * a non-zero seed. To use, subtract 1 and compare against the
+ * threshold with </>=. This lets threshold = 0 never match (0% hit),
+ * and threshold = UINT64_MAX always match (100% hit).
+ */
+ uint64_t seed;
bool write_op; /* writes alternate between insertions and removals */
bool resize_down;
} QEMU_ALIGNED(64); /* avoid false sharing among threads */
@@ -131,8 +137,9 @@ static uint64_t xorshift64star(uint64_t x)
static void do_rz(struct thread_info *info)
{
struct thread_stats *stats = &info->stats;
+ uint64_t r = info->seed - 1;
- if (info->r < resize_threshold) {
+ if (r < resize_threshold) {
size_t size = info->resize_down ? resize_min : resize_max;
bool resized;
@@ -151,13 +158,14 @@ static void do_rz(struct thread_info *info)
static void do_rw(struct thread_info *info)
{
struct thread_stats *stats = &info->stats;
+ uint64_t r = info->seed - 1;
uint32_t hash;
long *p;
- if (info->r >= update_threshold) {
+ if (r >= update_threshold) {
bool read;
- p = &keys[info->r & (lookup_range - 1)];
+ p = &keys[r & (lookup_range - 1)];
hash = hfunc(*p);
read = qht_lookup(&ht, p, hash);
if (read) {
@@ -166,7 +174,7 @@ static void do_rw(struct thread_info *info)
stats->not_rd++;
}
} else {
- p = &keys[info->r & (update_range - 1)];
+ p = &keys[r & (update_range - 1)];
hash = hfunc(*p);
if (info->write_op) {
bool written = false;
@@ -208,7 +216,7 @@ static void *thread_func(void *p)
rcu_read_lock();
while (!atomic_read(&test_stop)) {
- info->r = xorshift64star(info->r);
+ info->seed = xorshift64star(info->seed);
info->func(info);
}
rcu_read_unlock();
@@ -221,7 +229,7 @@ static void *thread_func(void *p)
static void prepare_thread_info(struct thread_info *info, int i)
{
/* seed for the RNG; each thread should have a different one */
- info->r = (i + 1) ^ time(NULL);
+ info->seed = (i + 1) ^ time(NULL);
/* the first update will be a write */
info->write_op = true;
/* the first resize will be down */
--
2.20.1
- [PULL 17/41] gitlab-ci: Fix the change rules after moving the YML files, (continued)
- [PULL 17/41] gitlab-ci: Fix the change rules after moving the YML files, Alex Bennée, 2020/07/07
- [PULL 27/41] tests/acceptance: skip LinuxInitrd 2gib with v4.16 on GitLab, Alex Bennée, 2020/07/07
- [PULL 36/41] containers.yml: build with docker.py tooling, Alex Bennée, 2020/07/07
- [PULL 25/41] tests/acceptance: fix dtb path for machine_rx_gdbsim, Alex Bennée, 2020/07/07
- [PULL 34/41] gitlab: split build-disabled into two phases, Alex Bennée, 2020/07/07
- [PULL 35/41] gitlab: limit re-builds of the containers, Alex Bennée, 2020/07/07
- [PULL 23/41] tests/docker: add packages needed for check-acceptance, Alex Bennée, 2020/07/07
- [PULL 38/41] shippable: pull images from registry instead of building, Alex Bennée, 2020/07/07
- [PULL 32/41] gitlab: enable check-tcg for linux-user tests, Alex Bennée, 2020/07/07
- [PULL 26/41] tests/acceptance: skip multicore mips_malta tests on GitLab, Alex Bennée, 2020/07/07
- [PULL 40/41] tests/qht-bench: Adjust testing rate by -1,
Alex Bennée <=
- [PULL 24/41] tests/acceptance: skip s390x_ccw_vrtio_tcg on GitLab, Alex Bennée, 2020/07/07
- [PULL 21/41] gitlab: build containers with buildkit and metadata, Alex Bennée, 2020/07/07
- [PULL 22/41] tests/docker: add --registry support to tooling, Alex Bennée, 2020/07/07
- [PULL 33/41] gitlab: add avocado asset caching, Alex Bennée, 2020/07/07
- [PULL 19/41] gitlab: build all container images during CI, Alex Bennée, 2020/07/07
- [PULL 30/41] tests/docker: add a linux-user testing focused image, Alex Bennée, 2020/07/07
- [PULL 37/41] testing: add check-build target, Alex Bennée, 2020/07/07
- Re: [PULL 00/41] testing updates (vm, gitlab, misc build fixes), Alex Bennée, 2020/07/07
- Re: [PULL 00/41] testing updates (vm, gitlab, misc build fixes), Peter Maydell, 2020/07/09