public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v1] benchtests: Improve reliability of memcmp benchmarks
@ 2021-09-18 21:39 Noah Goldstein
  2021-09-23 15:48 ` Noah Goldstein
  2021-10-08 19:40 ` H.J. Lu
  0 siblings, 2 replies; 3+ messages in thread
From: Noah Goldstein @ 2021-09-18 21:39 UTC (permalink / raw)
  To: libc-alpha

No bug. Remove reallocation of bufs between implementation tests. Move
initialization outside of foreach implementation test loop. Increase
iteration count.

Generally before this commit was seeing a great deal of variability
between runs. The goal of this commit is to make the results more
reliable.

Benchtests build and bench-memcmp succeeding.
---
 benchtests/bench-memcmp.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/benchtests/bench-memcmp.c b/benchtests/bench-memcmp.c
index 744c7ec5ba..0d6a93bf29 100644
--- a/benchtests/bench-memcmp.c
+++ b/benchtests/bench-memcmp.c
@@ -63,7 +63,7 @@ static void
 do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s1,
 	     const CHAR *s2, size_t len, int exp_result)
 {
-  size_t i, iters = INNER_LOOP_ITERS8;
+  size_t i, iters = INNER_LOOP_ITERS_LARGE;
   timing_t start, stop, cur;
 
   TIMING_NOW (start);
@@ -103,20 +103,19 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
   json_attr_uint (json_ctx, "result", (double) exp_result);
   json_array_begin (json_ctx, "timings");
 
-  FOR_EACH_IMPL (impl, 0)
-    {
-      s1 = (CHAR *) (buf1 + align1);
-      s2 = (CHAR *) (buf2 + align2);
+  s1 = (CHAR *)(buf1 + align1);
+  s2 = (CHAR *)(buf2 + align2);
 
-      for (i = 0; i < len; i++)
-	s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % MAX_CHAR;
+  for (i = 0; i < len; i++)
+    s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % MAX_CHAR;
 
-      s1[len] = align1;
-      s2[len] = align2;
-      s2[len - 1] -= exp_result;
+  s1[len] = align1;
+  s2[len] = align2;
+  s2[len - 1] -= exp_result;
 
+  FOR_EACH_IMPL (impl, 0)
+    {
       do_one_test (json_ctx, impl, s1, s2, len, exp_result);
-      alloc_bufs ();
     }
 
   json_array_end (json_ctx);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] benchtests: Improve reliability of memcmp benchmarks
  2021-09-18 21:39 [PATCH v1] benchtests: Improve reliability of memcmp benchmarks Noah Goldstein
@ 2021-09-23 15:48 ` Noah Goldstein
  2021-10-08 19:40 ` H.J. Lu
  1 sibling, 0 replies; 3+ messages in thread
From: Noah Goldstein @ 2021-09-23 15:48 UTC (permalink / raw)
  To: GNU C Library

On Sat, Sep 18, 2021 at 4:39 PM Noah Goldstein <goldstein.w.n@gmail.com>
wrote:

> No bug. Remove reallocation of bufs between implementation tests. Move
> initialization outside of foreach implementation test loop. Increase
> iteration count.
>
> Generally before this commit was seeing a great deal of variability
> between runs. The goal of this commit is to make the results more
> reliable.
>
> Benchtests build and bench-memcmp succeeding.
> ---
>  benchtests/bench-memcmp.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/benchtests/bench-memcmp.c b/benchtests/bench-memcmp.c
> index 744c7ec5ba..0d6a93bf29 100644
> --- a/benchtests/bench-memcmp.c
> +++ b/benchtests/bench-memcmp.c
> @@ -63,7 +63,7 @@ static void
>  do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s1,
>              const CHAR *s2, size_t len, int exp_result)
>  {
> -  size_t i, iters = INNER_LOOP_ITERS8;
> +  size_t i, iters = INNER_LOOP_ITERS_LARGE;
>    timing_t start, stop, cur;
>
>    TIMING_NOW (start);
> @@ -103,20 +103,19 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t
> align2, size_t len,
>    json_attr_uint (json_ctx, "result", (double) exp_result);
>    json_array_begin (json_ctx, "timings");
>
> -  FOR_EACH_IMPL (impl, 0)
> -    {
> -      s1 = (CHAR *) (buf1 + align1);
> -      s2 = (CHAR *) (buf2 + align2);
> +  s1 = (CHAR *)(buf1 + align1);
> +  s2 = (CHAR *)(buf2 + align2);
>
> -      for (i = 0; i < len; i++)
> -       s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % MAX_CHAR;
> +  for (i = 0; i < len; i++)
> +    s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % MAX_CHAR;
>
> -      s1[len] = align1;
> -      s2[len] = align2;
> -      s2[len - 1] -= exp_result;
> +  s1[len] = align1;
> +  s2[len] = align2;
> +  s2[len - 1] -= exp_result;
>
> +  FOR_EACH_IMPL (impl, 0)
> +    {
>        do_one_test (json_ctx, impl, s1, s2, len, exp_result);
> -      alloc_bufs ();
>      }
>
>    json_array_end (json_ctx);
> --
> 2.25.1
>
>
Going to check this in unless there are any objections.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] benchtests: Improve reliability of memcmp benchmarks
  2021-09-18 21:39 [PATCH v1] benchtests: Improve reliability of memcmp benchmarks Noah Goldstein
  2021-09-23 15:48 ` Noah Goldstein
@ 2021-10-08 19:40 ` H.J. Lu
  1 sibling, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2021-10-08 19:40 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: GNU C Library, Carlos O'Donell

On Sat, Sep 18, 2021 at 2:39 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> No bug. Remove reallocation of bufs between implementation tests. Move
> initialization outside of foreach implementation test loop. Increase
> iteration count.
>
> Generally before this commit was seeing a great deal of variability
> between runs. The goal of this commit is to make the results more
> reliable.
>
> Benchtests build and bench-memcmp succeeding.
> ---
>  benchtests/bench-memcmp.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/benchtests/bench-memcmp.c b/benchtests/bench-memcmp.c
> index 744c7ec5ba..0d6a93bf29 100644
> --- a/benchtests/bench-memcmp.c
> +++ b/benchtests/bench-memcmp.c
> @@ -63,7 +63,7 @@ static void
>  do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s1,
>              const CHAR *s2, size_t len, int exp_result)
>  {
> -  size_t i, iters = INNER_LOOP_ITERS8;
> +  size_t i, iters = INNER_LOOP_ITERS_LARGE;
>    timing_t start, stop, cur;
>
>    TIMING_NOW (start);
> @@ -103,20 +103,19 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
>    json_attr_uint (json_ctx, "result", (double) exp_result);
>    json_array_begin (json_ctx, "timings");
>
> -  FOR_EACH_IMPL (impl, 0)
> -    {
> -      s1 = (CHAR *) (buf1 + align1);
> -      s2 = (CHAR *) (buf2 + align2);
> +  s1 = (CHAR *)(buf1 + align1);
> +  s2 = (CHAR *)(buf2 + align2);
>
> -      for (i = 0; i < len; i++)
> -       s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % MAX_CHAR;
> +  for (i = 0; i < len; i++)
> +    s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % MAX_CHAR;
>
> -      s1[len] = align1;
> -      s2[len] = align2;
> -      s2[len - 1] -= exp_result;
> +  s1[len] = align1;
> +  s2[len] = align2;
> +  s2[len - 1] -= exp_result;
>
> +  FOR_EACH_IMPL (impl, 0)
> +    {
>        do_one_test (json_ctx, impl, s1, s2, len, exp_result);
> -      alloc_bufs ();
>      }
>
>    json_array_end (json_ctx);
> --
> 2.25.1
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-08 19:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-18 21:39 [PATCH v1] benchtests: Improve reliability of memcmp benchmarks Noah Goldstein
2021-09-23 15:48 ` Noah Goldstein
2021-10-08 19:40 ` H.J. Lu

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 read-only IMAP folder(s) and NNTP newsgroup(s).