From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70043.outbound.protection.outlook.com [40.107.7.43]) by sourceware.org (Postfix) with ESMTPS id E35AE385C401 for ; Wed, 24 Aug 2022 14:44:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E35AE385C401 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Hu0Hgep0O2t+UNnAM2xteTesC7YvtKo8LYKxRVRiBfbY9e1LOyw0FtxSAFumVkkJ3/TFzHVer8YNSoqlEKkkkDGVoWojLOHuImipMMYTDbV6vxIPKTYVedWWoUeqju/JUH39OTbXbq7MDazAfJUebEvf50LaQVxSV747HkVisjhIMIdOTNOB1Jv5o3g1GTxMOyBtYkq5Wz1/KlNnFSK+KwKeH38htQz/N611MCDDqqAp4j29xGHwr7AE54o+oSq05EwI3eJPU604gAnRqcD3Xvf7PynwJtcaIhCEUWGejIn4L02n2sMJg8nJjqeYI5PPMHMa6ZRwZGTdjo1w5KwvQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w03fG9CUUTSggDAdcsoshV6s8w3tvebNJY/BweKQgRM=; b=gRWPeFuHRQZ2gsRudf7v+2UFHBeCPSoL5mg1+NOe7KoXUsOhSopneXrHHN1N+Xefn0RuyntjdMNtrXmlxDrAyQcOlX+Tr06Mv8C7xfLr6ev/fA1ch93A2reHaeiTaCRfIUhugviqV6uiCnj75heLjMBY/TOvobi0Bvvr/4Emg0GhPWxXZLXgh08/V30oeNKebX+EjyNbDWfdaXyJRBoyn3BSFcIFrDero0Om5j0Uk51gm8hWcNR/mPEPu5vzoTRegMB1PCKB5CE7/NL0WnfHonOUWG73I01Yh9cRYtC9kHGvkvPKmWDzpl2Lsfok/mU+BTzmUka/MA5U0mSsDdsBcg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w03fG9CUUTSggDAdcsoshV6s8w3tvebNJY/BweKQgRM=; b=iRY+J1ozoaOOFpplsRc9r9k/19KhkQWBasAvSStmcRo0bTaWXhVINZTvWJx4fmtDq7iOBb5BLANK7af+CYd9MZuE8u90aQSq8G+ts5ayjGNBxUaPUI0o2LS0UqwPs7HM2KLvS6de7kmPEOexxu+svum/x1xwUyaK9/7VeW/21Ag= Received: from FR0P281CA0068.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::13) by AS8PR08MB6501.eurprd08.prod.outlook.com (2603:10a6:20b:338::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.18; Wed, 24 Aug 2022 14:44:01 +0000 Received: from VE1EUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:49:cafe::44) by FR0P281CA0068.outlook.office365.com (2603:10a6:d10:49::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15 via Frontend Transport; Wed, 24 Aug 2022 14:43:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT057.mail.protection.outlook.com (10.152.19.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.15 via Frontend Transport; Wed, 24 Aug 2022 14:43:59 +0000 Received: ("Tessian outbound c883b5ba7b70:v123"); Wed, 24 Aug 2022 14:43:59 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e2648b85c3a417bc X-CR-MTA-TID: 64aa7808 Received: from db9f98a79568.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 52DC4101-FB8D-404A-B1B2-1AF743B5CE03.1; Wed, 24 Aug 2022 14:43:52 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id db9f98a79568.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 24 Aug 2022 14:43:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=THJbYqlUz34wEV7XeB6PA8nhz3aFRkPTEZE5O6RMXXfAsWhVkEiYRAdJQHpFpswXU0Vq+5haJEJUd4MCoWXt/qNgy8w5OR2xNyNrAGW+bBvN0z4JNKsiitUYB4OhGwyTZLMq2m+DrgddiaI0KRWNg8JbXQzq22oNFVn4WaOnZa/akoGxfhFdM3TEmwimuaseniyaB18VNDVl9v3QANYxQgdWt+I60uMFEZ+C3wIzWtsN/oTcdcILP9ExGbihkIHpNumzrwijKTeURRXvJ1J0I/VGkgBdMPB8bRA+4EUqMzVmvpJQMynUYtumPshubsKUkCp0rLT5dABYngBZTorRhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w03fG9CUUTSggDAdcsoshV6s8w3tvebNJY/BweKQgRM=; b=ntL9vx63qGC6hblxH2RD8arqxmB3knCtciS7y1RTfAKzEKD6nPEnWDr+HS7hozssRHNAeDB17ZPO+vBRRXJA0zxrlQFOc2/j77ufh/n3gGKG35q/UlYc9CNF/cm7l+vN7KCmThFKHgoz9aBzFPRrq2aClEnW05CPAFZYqROLin3dRfYB7RmD2G8Jy6IK5OmUiPsh5tORjaqHatnVddBgTTWsqp1GIbV+3BqmImcCYnqUiZLWgu2WFLCBWRhwqxv9y5GCB2T7nqqi1V6+zYzEdytkbX6lOkKc7Z9dVeICoN68ztT46jlawN9DSTZY5CdUQ7mgGrQ061mrgR9JjeK6/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w03fG9CUUTSggDAdcsoshV6s8w3tvebNJY/BweKQgRM=; b=iRY+J1ozoaOOFpplsRc9r9k/19KhkQWBasAvSStmcRo0bTaWXhVINZTvWJx4fmtDq7iOBb5BLANK7af+CYd9MZuE8u90aQSq8G+ts5ayjGNBxUaPUI0o2LS0UqwPs7HM2KLvS6de7kmPEOexxu+svum/x1xwUyaK9/7VeW/21Ag= Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com (2603:10a6:203:3c::14) by AM9PR08MB6984.eurprd08.prod.outlook.com (2603:10a6:20b:417::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.19; Wed, 24 Aug 2022 14:43:46 +0000 Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::e434:1b13:e8ed:9e14]) by AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::e434:1b13:e8ed:9e14%12]) with mapi id 15.20.5546.024; Wed, 24 Aug 2022 14:43:46 +0000 From: Wilco Dijkstra To: Carlos O'Donell , 'GNU C Library' Subject: Re: [PATCH v2] Add random locking benchmark Thread-Topic: [PATCH v2] Add random locking benchmark Thread-Index: AQHYtjmErPPmS0gWSE6HojYzdbLo9q27a64AgAKzreY= Date: Wed, 24 Aug 2022 14:43:46 +0000 Message-ID: References: <6a3d9283-3866-e837-c348-6d2a4a701c4f@redhat.com> In-Reply-To: <6a3d9283-3866-e837-c348-6d2a4a701c4f@redhat.com> Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-MS-Office365-Filtering-Correlation-Id: 9e53aa3b-040b-4701-dd9c-08da85df149c x-ms-traffictypediagnostic: AM9PR08MB6984:EE_|VE1EUR03FT057:EE_|AS8PR08MB6501:EE_ x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: pKKRP+275A+qu4yh80DEYlGTu4WFcTxc5dLYHpyxT+aFYEacOD+A84rlZyYjJSkunlYpazSVAJG9D2NrHUVto/udSHrznC3PEWQzNErFd7Hv08kwwyMhYW5jSCv4lY4zHmBWCRSwuX0cC1lQqB/4b4azlnPHAcbiI+AK+MiyW/jXdJwhJ9LmSeFJLYjw92qEv7EIImugVp7raVvuvS6ijt9OGlNh1bHipjfq7jUjNVJ5g5gMpuKsU4pdnlYOUAPVQyn1gvpjmNsGl9beHM63HgacbCaTQNrOL8GOWBmMEjKzhjZLR5nkshC0uWI90V9Xq0woOU07nh+bn7yHkgzeBiadKXd8Fzav7XSpZnl8QwUaovJK7ojdCQrdrtz8JvIRLdbtfERRj0LpdMREWZQYTPcNrCiOXeU7+olfEI66t1trztk2zyxZspOCbGbQ6qAWqGIZr0YB07D5xSnPTukLljwrJvbwEK698ni/Qd4p+9HXovxQNf/B7GmrAuxS77drNHSBvGnchAmfn1rmJZIEl8U0Lh+hPy3iO6ebKdw2Ev+bud6avUhG/qsfikbudmbYF3M2agW16jLu6KxS9X1KmThmlVEvN27inlVlrJBpPQ2C/O2Ey2TBu2GiiRoAzbrbnlVS5/LY61i830ZIqUiAGi9GipWcLI5fhkucmr6VnSQf/Q9QztBr49noe0gyb8JQqEnWBxCEBjLBMHGzutwI8L5fnX03yPTAjzXYOtLPqDMkj/jRQg3j/jea7RaWUrNm8VAA0EPdfTkEo2IdX4Dgg9ouPr4KevToOaBUFtxCjRUdYRWk2i3mYO+GwZ4fASgV X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM5PR0801MB1668.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(366004)(346002)(39860400002)(396003)(376002)(136003)(64756008)(8676002)(66556008)(66476007)(91956017)(76116006)(86362001)(38100700002)(66946007)(110136005)(66446008)(33656002)(122000001)(38070700005)(26005)(6506007)(52536014)(9686003)(83380400001)(71200400001)(478600001)(41300700001)(186003)(7696005)(316002)(55016003)(2906002)(8936002)(5660300002)(2004002);DIR:OUT;SFP:1101; Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6984 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 602efde3-ef7d-4ed1-afd1-08da85df0c99 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kyjvNhrrT+Z699u1VUjnLzHWn6/DorEcZMmAEzlcuPuMhQ8XCW4ABbEvI+yDUJRor5GXdQ7ScOZP+PQhq7osH3CtUXXcTjKZrHowzr5hBCaW+aKC36ohw5eJgWuycYaFe203RKtys5KSpV9nEzlAZeOygfLGK0QefSBGClw34HgZSrk6uq5yginZAE5hQmsTl97aKy3lwHtWF3p2sm4gvx56F+D9pW+tUtNtw9mXNDkJFj/RXlecvKOtUuH2vJ1CFZg2s5bkct5si5ga455E00UDbogvHDwwfmpP/drmTYxQ0QgiP6WMKqWzTlYD3i+fWZF//sW5XinyNsfgEXHjWqFXzHMrc8CldP0+zYxYqgrIfj4zgEvLL0wq2aqgWtvcFeZMdFJ5+JP+r8yR/L9bIrLryRvMRcXjTOyQ/EE06IrTu4nDpCzrEGAlVMyRekk0xjrBF2oChhDUX4aEBvBpSjFAEAvvbn+pEXPww+EVpEi6uoyYFsSPjmU6Rr8pkLq8BXSYg0P7GVyJ0xeqlnevu+8hfI7qm3gehCk48+Fb7FdY7mOjGEvhM5Duqm0ehy4OzrXsbQlSutCYqwgR8WMwuLQt8qcbKVMb9/7tYUlMhiPHXRrF585GEay+p6MYIbNtoAUgPfmgWXL+neoFx8vsXukSGpbqwhjHw6I5fwSpVopoVvEnpW1Y+45ZUuubrxZ9yNgaBNuNXKtU0DxYK50ZQCaduK9fA/i41uEyOeE3REqyVRMSVXxavCKpNX/eLWGjo9KVdoUMmzPwZDfQ77DAFI4nX9q47G6ilHq/EOQYuwHu86rtJtMY7eHFlB8IMsxp X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230016)(4636009)(376002)(136003)(346002)(396003)(39860400002)(36840700001)(40470700004)(46966006)(186003)(6506007)(7696005)(33656002)(336012)(8936002)(9686003)(47076005)(5660300002)(26005)(52536014)(41300700001)(55016003)(83380400001)(86362001)(478600001)(40460700003)(81166007)(36860700001)(356005)(110136005)(316002)(82310400005)(8676002)(70586007)(70206006)(82740400003)(40480700001)(2906002)(2004002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2022 14:43:59.5278 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e53aa3b-040b-4701-dd9c-08da85df149c X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6501 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Carlos,=0A= =0A= > We could run the benchmark for a fixed amount of time, rather than a=0A= > fixed number of iterations, see bench-skeleton.c and DURATION.=0A= =0A= Unfortunately bench-skeleton is way too difficult to use - I'd just want to= =0A= give it a few functions to benchmark and let it do the rest. So it needs=0A= cleaning up before benchmarks can use it without a magic python script.=0A= =0A= I've updated the comments, see v3 below.=0A= =0A= Cheers,=0A= Wilco=0A= =0A= v3: Improve comments=0A= =0A= Add a simple benchmark to measure the overhead of internal libc=0A= locks in the random() implementation on both single- and=0A= multi-threaded cases. This relies on the implementation of random=0A= using internal locks to access shared global data, and that the runtime=0A= uses multi-threaded locking once a thread has been created (even after=0A= it finishes).=0A= =0A= ---=0A= diff --git a/benchtests/Makefile b/benchtests/Makefile=0A= index d99771be74b40f8afa3953f61c0721b19658d4b7..c413eac1d23568cb88bf22c6e50= 303e24ec10ea0 100644=0A= --- a/benchtests/Makefile=0A= +++ b/benchtests/Makefile=0A= @@ -236,6 +236,7 @@ hash-benchset :=3D \=0A= stdlib-benchset :=3D \=0A= arc4random \=0A= strtod \=0A= + random-lock \=0A= # stdlib-benchset=0A= =0A= stdio-common-benchset :=3D sprintf=0A= diff --git a/benchtests/bench-random-lock.c b/benchtests/bench-random-lock.= c=0A= new file mode 100644=0A= index 0000000000000000000000000000000000000000..c0aecb7f95b9f185df3bba7a75e= 3ef0884dbf6ce=0A= --- /dev/null=0A= +++ b/benchtests/bench-random-lock.c=0A= @@ -0,0 +1,109 @@=0A= +/* Benchmark internal libc locking functions used in random.=0A= + Copyright (C) 2022 Free Software Foundation, Inc.=0A= + This file is part of the GNU C Library.=0A= +=0A= + The GNU C Library is free software; you can redistribute it and/or=0A= + modify it under the terms of the GNU Lesser General Public=0A= + License as published by the Free Software Foundation; either=0A= + version 2.1 of the License, or (at your option) any later version.=0A= +=0A= + The GNU C Library is distributed in the hope that it will be useful,=0A= + but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU=0A= + Lesser General Public License for more details.=0A= +=0A= + You should have received a copy of the GNU Lesser General Public=0A= + License along with the GNU C Library; if not, see=0A= + . */=0A= +=0A= +#define TEST_MAIN=0A= +#define TEST_NAME "random-lock"=0A= +=0A= +#include =0A= +#include =0A= +#include =0A= +#include "bench-timing.h"=0A= +#include "json-lib.h"=0A= +=0A= +/* Modern cores run 20M iterations in about 1 second. */=0A= +#define NUM_ITERS 20000000=0A= +=0A= +json_ctx_t json_ctx;=0A= +=0A= +=0A= +/* Measure the overhead of __libc_lock_lock and __libc_lock_unlock by=0A= + calling random (). */=0A= +static void=0A= +bench_random_lock (size_t iters)=0A= +{=0A= + timing_t start, stop, total;=0A= +=0A= + srandom (0);=0A= +=0A= + /* Warmup to reduce variations due to frequency scaling. */=0A= + for (int i =3D 0; i < iters / 4; i++)=0A= + (void) random ();=0A= +=0A= + TIMING_NOW (start);=0A= +=0A= + for (int i =3D 0; i < iters; i++)=0A= + (void) random ();=0A= +=0A= + TIMING_NOW (stop);=0A= +=0A= + TIMING_DIFF (total, start, stop);=0A= +=0A= + json_element_double (&json_ctx, (double) total / (double) iters);=0A= +}=0A= +=0A= +static void *=0A= +thread_start (void *p)=0A= +{=0A= + return p;=0A= +}=0A= +=0A= +int=0A= +do_bench (void)=0A= +{=0A= + json_init (&json_ctx, 0, stdout);=0A= +=0A= + json_document_begin (&json_ctx);=0A= +=0A= + json_attr_string (&json_ctx, "timing_type", TIMING_TYPE);=0A= + json_attr_object_begin (&json_ctx, "functions");=0A= + json_attr_object_begin (&json_ctx, "random");=0A= + json_attr_string (&json_ctx, "bench-variant", "single-threaded");=0A= + json_array_begin (&json_ctx, "results");=0A= +=0A= + /* Run benchmark single threaded. */=0A= + bench_random_lock (NUM_ITERS);=0A= +=0A= + json_array_end (&json_ctx);=0A= + json_attr_object_end (&json_ctx);=0A= +=0A= + json_attr_object_begin (&json_ctx, "random");=0A= + json_attr_string (&json_ctx, "bench-variant", "multi-threaded");=0A= + json_array_begin (&json_ctx, "results");=0A= +=0A= + /* Start a short thread to force SINGLE_THREAD_P =3D=3D false. This rel= ies on=0A= + the runtime disabling single-threaded optimizations when multiple=0A= + threads are used, even after they finish. */=0A= +=0A= + pthread_t t;=0A= + pthread_create (&t, NULL, thread_start, NULL);=0A= + pthread_join (t, NULL);=0A= +=0A= + /* Repeat benchmark with single-threaded optimizations disabled. */=0A= + bench_random_lock (NUM_ITERS);=0A= +=0A= + json_array_end (&json_ctx);=0A= + json_attr_object_end (&json_ctx);=0A= + json_attr_object_end (&json_ctx);=0A= + json_document_end (&json_ctx);=0A= + return 0;=0A= +}=0A= +=0A= +#define TEST_FUNCTION do_bench ()=0A= +=0A= +#include "../test-skeleton.c"=0A= +=0A= =0A=