From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RDNS_DYNAMIC,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id C4D811F8C6 for ; Tue, 24 Aug 2021 15:21:28 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A519E3858020 for ; Tue, 24 Aug 2021 15:21:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A519E3858020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1629818487; bh=K+T37b7y0okh2mBa92e7IoRjV26Oe2JTSwdyzLKNGPg=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=JdQjWe+NsCzqke8MH7jiKpgjjZ/LhCCOnU/8+NRDHz3f53lL5C/XqpjvuI+c/hrI2 NPfGly/CGSku7+N5tT/hJ/pP5dZOeRsSFEYB1pD1x19FK0XwHaD0iqyCZLvFL0aNaz kTbyxn9sUbOOmKDqkajqWUuh6lAD3WEvjQ7fpj1A= Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 7A0843858410 for ; Tue, 24 Aug 2021 15:19:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7A0843858410 Received: by mail-pl1-x62e.google.com with SMTP id a5so12443486plh.5 for ; Tue, 24 Aug 2021 08:19:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=K+T37b7y0okh2mBa92e7IoRjV26Oe2JTSwdyzLKNGPg=; b=SyOrTu5f/6eBOcwd5OsHj3ozYDHM0rIpRb+3QyMVSizF1VEVetwWOEIcn6+h+z2p2W as6pbrV/tKcFFcyRwDJTu0hzVsn1eHCBemc9y8P48mm2ZEgwn1ZEqfNj8xckaDcxwLqm b+UfgN0s8YqAe3fv/UyFMlLJix1a6CF/xOQEbsarV6ijh3h8QlXlsusNy9SNDQ3fNC// 2VaAqY/TOTvZ8zb/oiIYTumioUTRiM1Rg9t1SdodvQSCbUrq3rG6YpEKVxIa0DcZsT31 OtXW6Yf5d7FqZFwM8SX8MNufOXEeFDB8M1L/1hD+IGMmFrgglVLj1oqHqwilBvz6zYeX JlCw== X-Gm-Message-State: AOAM532npVOcWUvEsyfIkVVa7fLSsTrdiv3lW+joq6S9XBigRq2lHzkZ sp3b3vGEk9jvBGLpKbIVrpQS8GOhjsxaVdGNH7Y= X-Google-Smtp-Source: ABdhPJw0XGh2yY25WyHBO9/jE6JyYc8FNFKKSCN/kIeLDdVO/tNWj73CWsL6OutrJ7VoqsLB17yeJUc9tsBDQQbOoos= X-Received: by 2002:a17:90a:2a88:: with SMTP id j8mr4978051pjd.153.1629818351588; Tue, 24 Aug 2021 08:19:11 -0700 (PDT) MIME-Version: 1.0 References: <20210824082753.3356637-1-goldstein.w.n@gmail.com> <20210824082753.3356637-3-goldstein.w.n@gmail.com> In-Reply-To: <20210824082753.3356637-3-goldstein.w.n@gmail.com> Date: Tue, 24 Aug 2021 08:18:35 -0700 Message-ID: Subject: Re: [PATCH 3/5] benchtests: Add partial overlap case in bench-memmove-walk.c To: Noah Goldstein Content-Type: text/plain; charset="UTF-8" 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: , From: "H.J. Lu via Libc-alpha" Reply-To: "H.J. Lu" Cc: GNU C Library Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On Tue, Aug 24, 2021 at 1:28 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. > --- > benchtests/bench-memmove-walk.c | 67 ++++++++++++++++++++++++--------- > 1 file changed, 49 insertions(+), 18 deletions(-) > > diff --git a/benchtests/bench-memmove-walk.c b/benchtests/bench-memmove-walk.c > index b5fdb2a422..18b716f5cb 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"); > - > - if (overlap) > - buf2 = buf1; > - > - 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); > + char *s1, *s2, *tmp; > + size_t repeats; > + > + s1 = (char *) (buf1); > + s2 = (char *) (buf2); > + if (overlap != NO_OVERLAP) > + s2 = s1; > + if (overlap == PARTIAL_OVERLAP) > + s2 += len / 2; > + > + 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); > + > + 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.