From: "H.J. Lu" <hjl.tools@gmail.com>
To: Noah Goldstein <goldstein.w.n@gmail.com>
Cc: libc-alpha@sourceware.org, carlos@systemhalted.org
Subject: Re: [PATCH v1 3/5] benchtests: Add partial overlap case in bench-memmove-walk.c
Date: Fri, 5 Nov 2021 19:28:15 -0700 [thread overview]
Message-ID: <YYXoP3E94Wz2Sq7V@gmail.com> (raw)
In-Reply-To: <20211101054952.2349590-3-goldstein.w.n@gmail.com>
On Mon, Nov 01, 2021 at 12:49:50AM -0500, Noah Goldstein wrote:
> This commit adds a new partial overlap benchmark. This is generally
> the most interesting performance case for memmove and was missing.
> ---
> benchtests/bench-memmove-walk.c | 61 +++++++++++++++++++++++++--------
> 1 file changed, 46 insertions(+), 15 deletions(-)
>
> diff --git a/benchtests/bench-memmove-walk.c b/benchtests/bench-memmove-walk.c
> index b5fdb2a422..2fb484c0ba 100644
> --- a/benchtests/bench-memmove-walk.c
> +++ b/benchtests/bench-memmove-walk.c
> @@ -36,6 +36,10 @@
> # define TIMEOUT (20 * 60)
> # include "bench-string.h"
>
> +#define NO_OVERLAP 0
> +#define PARTIAL_OVERLAP 1
> +#define COMPLETE_OVERLAP 2
> +
> IMPL (memmove, 1)
> #endif
>
> @@ -66,20 +70,40 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src,
> }
>
> static void
> -do_test (json_ctx_t *json_ctx, size_t len, bool overlap)
> +do_test (json_ctx_t *json_ctx, size_t len, int overlap, int both_ways)
> {
> - json_element_object_begin (json_ctx);
> - json_attr_uint (json_ctx, "length", (double) len);
> - json_array_begin (json_ctx, "timings");
> + char *s1, *s2, *tmp;
> + size_t repeats;
>
> - if (overlap)
> - buf2 = buf1;
> + s1 = (char *) (buf1);
> + s2 = (char *) (buf2);
> + if (overlap != NO_OVERLAP)
> + s2 = s1;
> + if (overlap == PARTIAL_OVERLAP)
> + s2 += len / 2;
>
> - FOR_EACH_IMPL (impl, 0)
> - do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, len);
> + for (repeats = both_ways ? 2 : 1; repeats; --repeats)
> + {
> + json_element_object_begin (json_ctx);
> + json_attr_uint (json_ctx, "length", (double) len);
> + json_attr_string(json_ctx, "overlap",
> + overlap == NO_OVERLAP ? "none"
> + : overlap == PARTIAL_OVERLAP ? "partial"
> + : "complete");
> + json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
> + json_array_begin (json_ctx, "timings");
> +
> +
> + FOR_EACH_IMPL (impl, 0)
> + do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, len);
>
> - json_array_end (json_ctx);
> - json_element_object_end (json_ctx);
> + json_array_end (json_ctx);
> + json_element_object_end (json_ctx);
> +
> + tmp = s1;
> + s1 = s2;
> + s2 = tmp;
> + }
> }
>
> int
> @@ -107,15 +131,22 @@ test_main (void)
> /* Non-overlapping buffers. */
> for (size_t i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
> {
> - do_test (&json_ctx, i, false);
> - do_test (&json_ctx, i + 1, false);
> + do_test (&json_ctx, i, NO_OVERLAP, 1);
> + do_test (&json_ctx, i + 1, NO_OVERLAP, 1);
> + }
> +
> + /* Partially-overlapping buffers. */
> + for (size_t i = START_SIZE; i <= MIN_PAGE_SIZE / 2; i <<= 1)
> + {
> + do_test (&json_ctx, i, PARTIAL_OVERLAP, 1);
> + do_test (&json_ctx, i + 1, PARTIAL_OVERLAP, 1);
> }
>
> - /* Overlapping buffers. */
> + /* Complete-overlapping buffers. */
> for (size_t i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
> {
> - do_test (&json_ctx, i, true);
> - do_test (&json_ctx, i + 1, true);
> + do_test (&json_ctx, i, COMPLETE_OVERLAP, 0);
> + do_test (&json_ctx, i + 1, COMPLETE_OVERLAP, 0);
> }
>
> json_array_end (&json_ctx);
> --
> 2.25.1
>
LGTM.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Thanks.
H.J.
next prev parent reply other threads:[~2021-11-06 2:28 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-01 5:49 [PATCH v1 1/5] string: Make tests birdirectional test-memcpy.c Noah Goldstein
2021-11-01 5:49 ` [PATCH v1 2/5] benchtests: Add additional cases to bench-memcpy.c and bench-memmove.c Noah Goldstein
2021-11-06 2:27 ` H.J. Lu
2021-11-01 5:49 ` [PATCH v1 3/5] benchtests: Add partial overlap case in bench-memmove-walk.c Noah Goldstein
2021-11-06 2:28 ` H.J. Lu [this message]
2021-11-01 5:49 ` [PATCH v1 4/5] x86: Optimize memmove-vec-unaligned-erms.S Noah Goldstein
2021-11-01 5:52 ` Noah Goldstein
2021-11-06 2:29 ` H.J. Lu
2021-11-01 5:49 ` [PATCH v1 5/5] x86: Double size of ERMS rep_movsb_threshold in dl-cacheinfo.h Noah Goldstein
2021-11-06 2:31 ` H.J. Lu
2021-11-06 4:39 ` Noah Goldstein
2021-11-06 12:04 ` H.J. Lu
2021-11-06 17:38 ` Noah Goldstein
2021-11-06 2:27 ` [PATCH v1 1/5] string: Make tests birdirectional test-memcpy.c H.J. Lu
2021-11-06 4:39 ` [PATCH v2 " Noah Goldstein
2021-11-06 4:39 ` [PATCH v2 2/5] benchtests: Add additional cases to bench-memcpy.c and bench-memmove.c Noah Goldstein
2021-11-06 4:39 ` [PATCH v2 3/5] benchtests: Add partial overlap case in bench-memmove-walk.c Noah Goldstein
2021-11-06 4:39 ` [PATCH v2 4/5] x86: Optimize memmove-vec-unaligned-erms.S Noah Goldstein
2021-11-06 4:39 ` [PATCH v2 5/5] x86: Double size of ERMS rep_movsb_threshold in dl-cacheinfo.h Noah Goldstein
2021-11-06 17:37 ` [PATCH v3 1/5] string: Make tests birdirectional test-memcpy.c Noah Goldstein
2021-11-06 17:37 ` [PATCH v3 2/5] benchtests: Add additional cases to bench-memcpy.c and bench-memmove.c Noah Goldstein
2021-11-06 17:37 ` [PATCH v3 3/5] benchtests: Add partial overlap case in bench-memmove-walk.c Noah Goldstein
2021-11-06 17:37 ` [PATCH v3 4/5] x86: Optimize memmove-vec-unaligned-erms.S Noah Goldstein
2021-11-06 17:37 ` [PATCH v3 5/5] x86: Double size of ERMS rep_movsb_threshold in dl-cacheinfo.h Noah Goldstein
2021-11-06 17:56 ` H.J. Lu
2021-11-06 18:11 ` Noah Goldstein
2021-11-06 18:21 ` H.J. Lu
2021-11-06 18:34 ` Noah Goldstein
2021-11-06 18:33 ` [PATCH v4 1/5] string: Make tests birdirectional test-memcpy.c Noah Goldstein
2021-11-06 18:33 ` [PATCH v4 2/5] benchtests: Add additional cases to bench-memcpy.c and bench-memmove.c Noah Goldstein
2021-11-06 19:12 ` H.J. Lu
2021-11-06 18:33 ` [PATCH v4 3/5] benchtests: Add partial overlap case in bench-memmove-walk.c Noah Goldstein
2021-11-06 19:11 ` H.J. Lu
2021-11-06 18:33 ` [PATCH v4 4/5] x86: Optimize memmove-vec-unaligned-erms.S Noah Goldstein
2021-11-06 19:11 ` H.J. Lu
2022-04-23 1:41 ` Sunil Pandey
2021-11-06 18:33 ` [PATCH v4 5/5] x86: Double size of ERMS rep_movsb_threshold in dl-cacheinfo.h Noah Goldstein
2021-11-06 19:10 ` H.J. Lu
2022-04-23 1:42 ` Sunil Pandey
2021-11-06 19:12 ` [PATCH v4 1/5] string: Make tests birdirectional test-memcpy.c H.J. Lu
2021-11-06 21:20 ` Noah Goldstein
2021-11-07 13:53 ` H.J. Lu
2021-12-07 21:10 ` Stafford Horne
2021-12-07 21:36 ` Noah Goldstein
2021-12-07 22:07 ` Stafford Horne
2021-12-07 22:13 ` Noah Goldstein
-- strict thread matches above, loose matches on Subject: below --
2021-08-24 8:27 [PATCH " Noah Goldstein
2021-08-24 19:32 ` [PATCH v1 " Noah Goldstein
2021-08-24 19:32 ` [PATCH v1 3/5] benchtests: Add partial overlap case in bench-memmove-walk.c Noah Goldstein
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=YYXoP3E94Wz2Sq7V@gmail.com \
--to=hjl.tools@gmail.com \
--cc=carlos@systemhalted.org \
--cc=goldstein.w.n@gmail.com \
--cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).