From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from brown.elm.relay.mailchannels.net (brown.elm.relay.mailchannels.net [23.83.212.23]) by sourceware.org (Postfix) with ESMTPS id 6F06D385843F for ; Fri, 29 Oct 2021 03:27:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6F06D385843F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 5E532341A83; Fri, 29 Oct 2021 03:27:42 +0000 (UTC) Received: from pdx1-sub0-mail-a53.g.dreamhost.com (100-96-18-144.trex.outbound.svc.cluster.local [100.96.18.144]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 6FAFC341911; Fri, 29 Oct 2021 03:27:41 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a53.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.18.144 (trex/6.4.3); Fri, 29 Oct 2021 03:27:42 +0000 X-MC-Relay: Junk X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Lettuce-Macabre: 26e31b3c4a80076d_1635478062174_3462361057 X-MC-Loop-Signature: 1635478062174:526705193 X-MC-Ingress-Time: 1635478062174 Received: from pdx1-sub0-mail-a53.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a53.g.dreamhost.com (Postfix) with ESMTP id 2ED4680671; Thu, 28 Oct 2021 20:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gotplt.org; h=message-id :date:mime-version:subject:to:references:from:in-reply-to :content-type:content-transfer-encoding; s=gotplt.org; bh=EYcLwi KtNItXUTkw7jWQGkSeayQ=; b=qR0RhXB5xTAgKOiGx3dDWaBBKma6PsLaL2ehSs 5gFaUtPCpRVZhpaq4dbOjAdJmqsF6BqiYvExapJwvoEewtNdpbS/kAHwLdfBpCrt dSVOZpAd+aZskqs/WhUAZFhrG9GyCbuRFlFtfyGgTLmFBQijswVfShmFor1eMvPC 1cjM4= Received: from [192.168.1.174] (unknown [1.186.223.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a53.g.dreamhost.com (Postfix) with ESMTPSA id 7B2777E613; Thu, 28 Oct 2021 20:27:38 -0700 (PDT) Message-ID: <46ddd7de-1dd9-dc9f-c32d-32b0bbd6a245@gotplt.org> Date: Fri, 29 Oct 2021 08:57:33 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH] Benchtests: Improve bench-memcpy-random Content-Language: en-US To: Wilco Dijkstra , 'GNU C Library' References: X-DH-BACKEND: pdx1-sub0-mail-a53 From: Siddhesh Poyarekar In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3038.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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: Fri, 29 Oct 2021 03:27:45 -0000 On 10/18/21 20:49, Wilco Dijkstra via Libc-alpha wrote: > Improve the random memcpy benchmark. Double the number of tests and increase > the size of the memory region to test between 32KB and 1024KB. This improves > accuracy on modern cores. Clean up formatting of the frequency array. > > OK for commit? LGTM. Reviewed-by: Siddhesh Poyarekar > > --- > > diff --git a/benchtests/bench-memcpy-random.c b/benchtests/bench-memcpy-random.c > index c490b73ed07bfb8287ab7a41ac2cfb7c43d1d545..b2edd8b7e3d5503953f22365ba2a6fd0eace6fbc 100644 > --- a/benchtests/bench-memcpy-random.c > +++ b/benchtests/bench-memcpy-random.c > @@ -16,15 +16,17 @@ > License along with the GNU C Library; if not, see > . */ > > -#define MIN_PAGE_SIZE (512*1024+getpagesize()) > +#define MIN_SIZE 32768 > +#define MAX_SIZE (1024*1024) > +#define NUM_TESTS 16384 > + > +#define MIN_PAGE_SIZE (MAX_SIZE + getpagesize()) > #define TEST_MAIN > #define TEST_NAME "memcpy" > #include "bench-string.h" > #include > #include "json-lib.h" > > -#define MAX_COPIES 8192 > - Renamed MAX_COPIES to NUM_TESTS macroized, loop range and bumped all of it up. OK. > IMPL (memcpy, 1) > > typedef struct { uint16_t size; uint16_t freq; } freq_data_t; > @@ -37,36 +39,36 @@ static uint8_t size_arr[SIZE_NUM]; > /* Frequency data for memcpy of less than 4096 bytes based on SPEC2017. */ > static freq_data_t size_freq[] = > { > -{ 32, 22320}, { 16, 9554}, { 8, 8915}, {152, 5327}, { 4, 2159}, {292, 2035}, > -{ 12, 1608}, { 24, 1343}, {1152, 895}, {144, 813}, {884, 733}, {284, 721}, > +{32,22320}, { 16,9554}, { 8,8915}, {152,5327}, { 4,2159}, {292,2035}, > +{ 12,1608}, { 24,1343}, {1152,895}, {144, 813}, {884, 733}, {284, 721}, > {120, 661}, { 2, 649}, {882, 550}, { 5, 475}, { 7, 461}, {108, 460}, > -{ 10, 361}, { 9, 361}, { 6, 334}, { 3, 326}, {464, 308}, {2048, 303}, > +{ 10, 361}, { 9, 361}, { 6, 334}, { 3, 326}, {464, 308}, {2048,303}, > { 1, 298}, { 64, 250}, { 11, 197}, {296, 194}, { 68, 187}, { 15, 185}, > -{192, 184}, {1764, 183}, { 13, 173}, {560, 126}, {160, 115}, {288, 96}, > -{104, 96}, {1144, 83}, { 18, 80}, { 23, 78}, { 40, 77}, { 19, 68}, > -{ 48, 63}, { 17, 57}, { 72, 54}, {1280, 51}, { 20, 49}, { 28, 47}, > +{192, 184}, {1764,183}, { 13, 173}, {560, 126}, {160, 115}, {288, 96}, > +{104, 96}, {1144, 83}, { 18, 80}, { 23, 78}, { 40, 77}, { 19, 68}, > +{ 48, 63}, { 17, 57}, { 72, 54}, {1280, 51}, { 20, 49}, { 28, 47}, > { 22, 46}, {640, 45}, { 25, 41}, { 14, 40}, { 56, 37}, { 27, 35}, > -{ 35, 33}, {384, 33}, { 29, 32}, { 80, 30}, {4095, 22}, {232, 22}, > +{ 35, 33}, {384, 33}, { 29, 32}, { 80, 30}, {4095, 22}, {232, 22}, > { 36, 19}, {184, 17}, { 21, 17}, {256, 16}, { 44, 15}, { 26, 15}, > -{ 31, 14}, { 88, 14}, {176, 13}, { 33, 12}, {1024, 12}, {208, 11}, > +{ 31, 14}, { 88, 14}, {176, 13}, { 33, 12}, {1024, 12}, {208, 11}, > { 62, 11}, {128, 10}, {704, 10}, {324, 10}, { 96, 10}, { 60, 9}, > -{136, 9}, {124, 9}, { 34, 8}, { 30, 8}, {480, 8}, {1344, 8}, > +{136, 9}, {124, 9}, { 34, 8}, { 30, 8}, {480, 8}, {1344, 8}, > {273, 7}, {520, 7}, {112, 6}, { 52, 6}, {344, 6}, {336, 6}, > {504, 5}, {168, 5}, {424, 5}, { 0, 4}, { 76, 3}, {200, 3}, > {512, 3}, {312, 3}, {240, 3}, {960, 3}, {264, 2}, {672, 2}, > { 38, 2}, {328, 2}, { 84, 2}, { 39, 2}, {216, 2}, { 42, 2}, > -{ 37, 2}, {1608, 2}, { 70, 2}, { 46, 2}, {536, 2}, {280, 1}, > -{248, 1}, { 47, 1}, {1088, 1}, {1288, 1}, {224, 1}, { 41, 1}, > +{ 37, 2}, {1608, 2}, { 70, 2}, { 46, 2}, {536, 2}, {280, 1}, > +{248, 1}, { 47, 1}, {1088, 1}, {1288, 1}, {224, 1}, { 41, 1}, > { 50, 1}, { 49, 1}, {808, 1}, {360, 1}, {440, 1}, { 43, 1}, > { 45, 1}, { 78, 1}, {968, 1}, {392, 1}, { 54, 1}, { 53, 1}, > { 59, 1}, {376, 1}, {664, 1}, { 58, 1}, {272, 1}, { 66, 1}, > -{2688, 1}, {472, 1}, {568, 1}, {720, 1}, { 51, 1}, { 63, 1}, > +{2688, 1}, {472, 1}, {568, 1}, {720, 1}, { 51, 1}, { 63, 1}, > { 86, 1}, {496, 1}, {776, 1}, { 57, 1}, {680, 1}, {792, 1}, > {122, 1}, {760, 1}, {824, 1}, {552, 1}, { 67, 1}, {456, 1}, > {984, 1}, { 74, 1}, {408, 1}, { 75, 1}, { 92, 1}, {576, 1}, > {116, 1}, { 65, 1}, {117, 1}, { 82, 1}, {352, 1}, { 55, 1}, > {100, 1}, { 90, 1}, {696, 1}, {111, 1}, {880, 1}, { 79, 1}, > -{488, 1}, { 61, 1}, {114, 1}, { 94, 1}, {1032, 1}, { 98, 1}, > +{488, 1}, { 61, 1}, {114, 1}, { 94, 1}, {1032, 1}, { 98, 1}, > { 87, 1}, {584, 1}, { 85, 1}, {648, 1}, {0, 0} > }; Updated frequency data. OK. > > @@ -94,7 +96,7 @@ typedef struct > uint64_t len : 16; > } copy_t; > > -static copy_t copy[MAX_COPIES]; > +static copy_t test_arr[NUM_TESTS]; > > typedef char *(*proto_t) (char *, const char *, size_t); > > @@ -150,13 +152,13 @@ do_test (json_ctx_t *json_ctx, size_t max_size) > > /* Create a random set of copies with the given size and alignment > distributions. */ > - for (i = 0; i < MAX_COPIES; i++) > + for (i = 0; i < NUM_TESTS; i++) > { > - copy[i].dst = (rand () & (max_size - 1)); > - copy[i].dst &= ~dst_align_arr[rand () & ALIGN_MASK]; > - copy[i].src = (rand () & (max_size - 1)); > - copy[i].src &= ~src_align_arr[rand () & ALIGN_MASK]; > - copy[i].len = size_arr[rand () & SIZE_MASK]; > + test_arr[i].dst = (rand () & (max_size - 1)); > + test_arr[i].dst &= ~dst_align_arr[rand () & ALIGN_MASK]; > + test_arr[i].src = (rand () & (max_size - 1)); > + test_arr[i].src &= ~src_align_arr[rand () & ALIGN_MASK]; > + test_arr[i].len = size_arr[rand () & SIZE_MASK]; Renamed array. OK. > } > > json_element_object_begin (json_ctx); > @@ -164,7 +166,7 @@ do_test (json_ctx_t *json_ctx, size_t max_size) > json_array_begin (json_ctx, "timings"); > > FOR_EACH_IMPL (impl, 0) > - do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, copy, i); > + do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, test_arr, i); > > json_array_end (json_ctx); > json_element_object_end (json_ctx); > @@ -193,8 +195,8 @@ test_main (void) > json_array_end (&json_ctx); > > json_array_begin (&json_ctx, "results"); > - for (int i = 4; i <= 512; i = i * 2) > - do_test (&json_ctx, i * 1024); > + for (int i = MIN_SIZE; i <= MAX_SIZE; i = i * 2) > + do_test (&json_ctx, i); > > json_array_end (&json_ctx); > json_attr_object_end (&json_ctx); > OK. Thanks, Siddhesh