From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 021B53858D38 for ; Thu, 16 May 2024 14:58:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 021B53858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 021B53858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715871529; cv=none; b=Vog/FcS3FiMUdoMFybW86WkWNMYY+8l5uYpSl8TjsA+Iq0V/DFi7utgAmn+pCSAL4NDoKyyZPcdy+QRaqxnGmCixkFCa0qh1YxcqMQhyGyszn1xjdPLYfF/dzo5n2xCwTdsbiqayI4uM5wz74J+0LInXuNzC1siaove0LgwKfWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715871529; c=relaxed/simple; bh=R6Kcvb100d6D3B+JOzupSp7IZg3VWn4A7HpJXHMa9Qg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=x0XZFHp7K5Jfm8Xu3Ui14phIWrBgfNGEMpXWwDSpQ1gG+lnxjRPIUzXdRaNBX904gqShhWuSF0Q94+sIbxAuZG13aA939I6Yqac1Xg8THG+1btgejvF6x+jJnZgZXOtccle9pd+plRRAB8/VdJMQScXIDrM14nUmF9HwAqvtsrk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715871526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=AB9cmJKC3MuUfd5bCzbzoRO4zIunpQxyc3Xa/3dp7ZU=; b=Ln0N/g5TG+xsup07DyvxPIW0ax/S7CX0jGqZfkvqR5uOgpvgCYD1JPTpUOxxJxrBKHqbnM 4x0NzItFoTeOwncNkuQIiZNmAfSyt0BdYf7d1W4t9ckreQm9bpjUJbJ+cNYpYpdrmFqCxM bFDXsWJu2zgwCen3/7WE/WW7jYCo70o= Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-286-zHjLEfckM0KpT5FmzUeRWA-1; Thu, 16 May 2024 10:58:45 -0400 X-MC-Unique: zHjLEfckM0KpT5FmzUeRWA-1 Received: by mail-yb1-f198.google.com with SMTP id 3f1490d57ef6-de74a2635e2so13313619276.3 for ; Thu, 16 May 2024 07:58:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715871525; x=1716476325; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AB9cmJKC3MuUfd5bCzbzoRO4zIunpQxyc3Xa/3dp7ZU=; b=myIDC9FWXoEHFSu6iX0miuPjU789x+5YPIxHIjSZVl5CX2LZnRyelO4xNqcNZJxlg+ R9U+uywe7DXZrEJHCIFkhBm1lTISOvh9BrmVTorPzM0pr2Vts4GTOw6pypFPvMyRpi2K RiaMPZSGqgZFclVHYVeymopUaqxrogRdJCrsg7IseEhG43M5cxAeqMrqHRU+qrDZjdoa LYTx+zijAJrnKCVIlUHBi4lWsJH1Sql/PSOxXDbJEtCsFVOUh4KmWdN4L/Y2QNwd5pfL VqeHiE1/XEOmqG2V2EfgeazWEJrzbGOnnm/vGgMGcRSj/Lk96W+88BISpsA2tZY2AoO1 LKBA== X-Forwarded-Encrypted: i=1; AJvYcCVEefvjG/Tlcu6OejvWBC6I28dZ4bEWHmq+vYYhawGZIvlN+pHgQrotwXwQShDbi9saeCTWrGsvN9P1YQaFIUspDpQ0Vw5tacP+ X-Gm-Message-State: AOJu0YzZ0Ep7tN0Kdg3JEu337TTCns7n5vG79osY8FCIThBuyMeDPrsT WEdywY8YF5PuHu0l9OwK5GEPaJxyJzhNT/3hcnm/Iff7KB4I9JRKJ77UGbbtw5UWGekOqbN79U0 EdGT6IllBJaamyVr2jaLYffZV3BxXoWyOkTxyzRa2ohXWe6OR+Uzoe0LYkQ== X-Received: by 2002:a5b:14e:0:b0:de5:d2d5:8d46 with SMTP id 3f1490d57ef6-dee4f4bf9fcmr17705919276.58.1715871524721; Thu, 16 May 2024 07:58:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFchc3DE9dMnng05oSDBSwXlw46MUPSb3SXnMW1iPT0fss9YYdsjtDa2Ta5SWI5wBywEaZDVQ== X-Received: by 2002:a5b:14e:0:b0:de5:d2d5:8d46 with SMTP id 3f1490d57ef6-dee4f4bf9fcmr17705908276.58.1715871524343; Thu, 16 May 2024 07:58:44 -0700 (PDT) Received: from [192.168.0.241] ([198.48.244.52]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6a15f1cd266sm76141746d6.80.2024.05.16.07.58.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 May 2024 07:58:43 -0700 (PDT) Message-ID: Date: Thu, 16 May 2024 10:58:43 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] benchtests: Add fclose benchmark To: "H.J. Lu" , libc-alpha@sourceware.org References: <20240516135024.557291-1-hjl.tools@gmail.com> From: Carlos O'Donell Autocrypt: addr=carlos@redhat.com; keydata= xsFNBFef5BoBEACvJ15QMMZh4stKHbz0rs78XsOdxuug37dumTx6ngrDCwZ61k7nHQ+uxLuo QvLSc6YJGBEfiNFbs1hvhRFNR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Nk9M0GvTvPKoah9gkvL/+AofN/31ABEBAAHCwXwEGAEIACYCGwwWIQRyc1QrOZYt97KZkxQW eStOolNA+AUCZK2RDAUJDwAD8gAKCRAWeStOolNA+B0MEACVxFO++NroEQxSQ0NCWod3aDmY mYn+/08wLTeMP+ajq19FEjU0Lh/GBJl6WlSHeJ5ZJlNSiXZuiSYGMYm73DBaoZlyjbD+H9NL LwLXgtfCZYlN6Iu8JRMfk9yevVBay7Be9DkPAk565ggo0UkIjpYftiLF4TUfqnI1yO6QKXgr J2DDwlP3iiCYnWFpHdBTB2/BRurpZoRquhRGzgcdGfRDtp16Pzm/u8BjfaU5/AFRjM0IDYQ6 PaQld0uZSZ0qOn0ts6usJws5gANq4U1oWJlqL/PHOFy9mbwUnKqq0oiWrmj+Mb+Ic6m9fqB3 5CHWUhxC1QozvkuY/sTsmXnG/mnbq2oFIVcgXDsnrDHf+0GyR+TrE4AQw1Pt2utsmU67LqNB Ru/2NbSFgwPv5wWjtNwDVGSZEXlV4qJGjh8S9aaGXhRTwJsnN6qkFS1m6vHKwqnRb5Qy4XDg 7kDrhFnTWe+XSwQt+HtGvIiXcR3EScJky76YlVsWDtvZMo3NePaC3qV5HAC8d2ZL3sFqxJRu sRyjE2l6s0EEK2MUgV/dwodftECrMdGktndVTYPqLnsua/PWWKYwYrNvD8slL6VFkXDZvLLv nat9vl9mBm15b76RHvKNlRcPbB9YYCbS5fhN2ObAsVbV1c5TdBCp8lp1Fa3YK0TA+WpNZVHK vjq6hMJAjA== Organization: Red Hat In-Reply-To: <20240516135024.557291-1-hjl.tools@gmail.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP 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: On 5/16/24 9:50 AM, H.J. Lu wrote: > Measure duration of 100 fclose calls after opening 1 million FILEs. Fantastic idea. I'd like to see the results of this for the doubly-linked list change. OK to keep my Reviewed-by: and push if you only change the copyright notice as requested. Reviewed-by: Carlos O'Donell > Signed-off-by: H.J. Lu > --- > benchtests/Makefile | 6 ++++ > benchtests/README | 1 + > benchtests/bench-fclose.c | 74 +++++++++++++++++++++++++++++++++++++++ > 3 files changed, 81 insertions(+) > create mode 100644 benchtests/bench-fclose.c > > diff --git a/benchtests/Makefile b/benchtests/Makefile > index 7e73b8504e..b74b5fe1ad 100644 > --- a/benchtests/Makefile > +++ b/benchtests/Makefile > @@ -261,6 +261,10 @@ stdlib-benchset := \ > strtod \ > # stdlib-benchset > > +stdio-benchset := \ > + fclose \ > + # stdio-benchset > + > stdio-common-benchset := sprintf > > math-benchset := math-inlines > @@ -269,6 +273,7 @@ ifeq (${BENCHSET},) > benchset := \ > $(hash-benchset) \ > $(math-benchset) \ > + $(stdio-benchset) \ > $(stdio-common-benchset) \ > $(stdlib-benchset) \ > $(string-benchset-all) \ > @@ -419,6 +424,7 @@ VALIDBENCHSETNAMES := \ > malloc-simple \ > malloc-thread \ > math-benchset \ > + stdio-benchset \ > stdio-common-benchset \ > stdlib-benchset \ > string-benchset \ > diff --git a/benchtests/README b/benchtests/README > index 998ba9b2b4..15d014a407 100644 > --- a/benchtests/README > +++ b/benchtests/README > @@ -87,6 +87,7 @@ where BENCHSET may be a space-separated list of the following values: > hash-benchset > malloc-thread > math-benchset > + stdio-benchset > stdio-common-benchset > stdlib-benchset > string-benchset > diff --git a/benchtests/bench-fclose.c b/benchtests/bench-fclose.c > new file mode 100644 > index 0000000000..c1cdf03169 > --- /dev/null > +++ b/benchtests/bench-fclose.c > @@ -0,0 +1,74 @@ > +/* Benchmark fclose. > + Copyright (C) 2024 Free Software Foundation, Inc. Should have "Copyright The GNU Toolchain Authors." since you are contributing under DCO a file that is a combination of copying from an existing benchtests file and adding your own changes. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#include > +#include > +#include > +#include "bench-timing.h" > +#include "json-lib.h" > + > +#define NUM_FILES 1000000 OK. I accept that on some systems this may fail due to the open files limit, but this is for microbenchmarking so the system needs to be adjusted for that. In the future we might want to run a small sanity checking program as the first thing in the microbenchmark run that tests for all of these conditions. OK for now. > +#define NUM_FCLOSE 100 > + > +int > +main (int argc, char **argv) > +{ > + json_ctx_t json_ctx; > + json_init (&json_ctx, 0, stdout); > + json_document_begin (&json_ctx); > + > + json_attr_string (&json_ctx, "timing_type", TIMING_TYPE); > + json_attr_object_begin (&json_ctx, "functions"); > + json_attr_object_begin (&json_ctx, "fclose"); > + > + FILE *ff, *keep[NUM_FCLOSE]; > + int i; > + > + for (i = 0; i < NUM_FILES; i++) > + { > + ff = fdopen (STDIN_FILENO, "r"); > + if (!ff) > + { > + fprintf (stderr, "### failed to fdopen: %m\n"); > + return EXIT_FAILURE; > + } > + if (i < NUM_FCLOSE) > + keep[i] = ff; > + } > + > + timing_t start, stop, elapsed; > + > + TIMING_NOW (start); > + > + for (i = 0; i < NUM_FCLOSE; i++) > + fclose (keep[i]); > + > + TIMING_NOW (stop); > + > + TIMING_DIFF (elapsed, start, stop); > + > + json_attr_uint (&json_ctx, "number of FILEs", NUM_FILES); > + json_attr_uint (&json_ctx, "number of fclose calls", NUM_FCLOSE); > + json_attr_uint (&json_ctx, "duration", elapsed); > + > + json_attr_object_end (&json_ctx); > + json_attr_object_end (&json_ctx); > + json_document_end (&json_ctx); > + > + return 0; > +} -- Cheers, Carlos.