From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, "Emilio G . Cota" <cota@braap.org>,
alex.bennee@linaro.org
Subject: [PATCH] tests/qht-bench: Adjust rate computation and comparisons
Date: Sat, 20 Jun 2020 14:45:51 -0700 [thread overview]
Message-ID: <20200620214551.447392-1-richard.henderson@linaro.org> (raw)
Use <= comparisons vs the threshold, so that threshold UINT64_MAX
is always true, corresponding to rate 1.0 being unity. Simplify
do_threshold scaling to 2**64, with a special case for 1.0.
Cc: Emilio G. Cota <cota@braap.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tests/qht-bench.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/tests/qht-bench.c b/tests/qht-bench.c
index eb88a90137..21b1b7de82 100644
--- a/tests/qht-bench.c
+++ b/tests/qht-bench.c
@@ -132,7 +132,7 @@ static void do_rz(struct thread_info *info)
{
struct thread_stats *stats = &info->stats;
- if (info->r < resize_threshold) {
+ if (info->r <= resize_threshold) {
size_t size = info->resize_down ? resize_min : resize_max;
bool resized;
@@ -154,7 +154,7 @@ static void do_rw(struct thread_info *info)
uint32_t hash;
long *p;
- if (info->r >= update_threshold) {
+ if (info->r > update_threshold) {
bool read;
p = &keys[info->r & (lookup_range - 1)];
@@ -281,11 +281,18 @@ static void pr_params(void)
static void do_threshold(double rate, uint64_t *threshold)
{
+ /*
+ * For 0 <= rate <= 1, scale to fit in a uint64_t.
+ *
+ * For rate == 1, returning UINT64_MAX means 100% certainty: all
+ * uint64_t will match using <=. The largest representable value
+ * for rate less than 1 is 0.999999999999999889; scaling that
+ * by 2**64 results in 0xfffffffffffff800.
+ */
if (rate == 1.0) {
*threshold = UINT64_MAX;
} else {
- *threshold = (rate * 0xffff000000000000ull)
- + (rate * 0x0000ffffffffffffull);
+ *threshold = rate * 0x1p64;
}
}
--
2.25.1
next reply other threads:[~2020-06-20 21:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-20 21:45 Richard Henderson [this message]
2020-06-21 21:28 ` [PATCH] tests/qht-bench: Adjust rate computation and comparisons Emilio G. Cota
2020-06-23 1:57 ` Emilio G. Cota
2020-06-23 22:37 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200620214551.447392-1-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=cota@braap.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).