From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id 484913857C7A for ; Sat, 6 Nov 2021 19:12:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 484913857C7A Received: by mail-pj1-x102e.google.com with SMTP id y14-20020a17090a2b4e00b001a5824f4918so5676947pjc.4 for ; Sat, 06 Nov 2021 12:12:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ET7mL2ONUVhcYMvINi16DDWmVmaWvTys7/Tp34Eep/A=; b=TZ9eTgSQtp514Mbb/SqJB31meUxc+PaCBuuu+j3rzSGqswYhZ19+G/ExwmEml8CyjJ PPNehAnMARCC4/fQj808p1s8tztlSEh1aOlBikXwDaCAF5Qd2gGIb3aR/CT4d7eetRMS hcztQzzU9ChWGqHYRj0QJIA17RfyHNVjNcVtR51qzAvWIaXxexfoxPjqnq1rU9G73r6f SECkDETZ2wGabjcbNPzwFOG0XMGZfnd+CVQ8Fwif2cRJoXaDCp/j1iGdOmJ+3tp/krCZ Qw6/VIkEu9ysQv0UC+sosHImtuufYl+ya4ipk2ZVALNI3qNYWHb8YB4KVULrRJHv4Nnq FUow== X-Gm-Message-State: AOAM533GqhpJ6VbQw5foo1NldqKskl57TNTYeBgh1I5+Ur6wghF0GNzL l3W/OlYZePmGTFMT7IqfAWcMuhqKcSjLpavqzmE= X-Google-Smtp-Source: ABdhPJyxjECDmsVtw7AfaKwz7oQbuLLrH0FMp2el8m5stDWdnSUdjdZD5UlfcAPaM1ZYPYxjlVl8rD4i0Ic5CrHUBiY= X-Received: by 2002:a17:90b:3a85:: with SMTP id om5mr40234876pjb.28.1636225937308; Sat, 06 Nov 2021 12:12:17 -0700 (PDT) MIME-Version: 1.0 References: <20211101054952.2349590-1-goldstein.w.n@gmail.com> <20211106183322.3129442-1-goldstein.w.n@gmail.com> <20211106183322.3129442-3-goldstein.w.n@gmail.com> In-Reply-To: <20211106183322.3129442-3-goldstein.w.n@gmail.com> From: "H.J. Lu" Date: Sat, 6 Nov 2021 12:11:41 -0700 Message-ID: Subject: Re: [PATCH v4 3/5] benchtests: Add partial overlap case in bench-memmove-walk.c To: Noah Goldstein Cc: GNU C Library , "Carlos O'Donell" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3029.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2021 19:12:19 -0000 On Sat, Nov 6, 2021 at 11:33 AM Noah Goldstein wrote: > > This commit adds a new partial overlap benchmark. This is generally > the most interesting performance case for memmove and was missing. > Reviewed-by: H.J. Lu > --- > 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 Thanks. -- H.J.