From patchwork Sat May 3 10:48:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Bilka X-Patchwork-Id: 797 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id A044436128F for ; Sat, 3 May 2014 03:48:43 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14307373) id 2F6BD636669AD; Sat, 3 May 2014 03:48:43 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id 0A57D636669A5 for ; Sat, 3 May 2014 03:48:43 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=sFXh CxsIFksrQdU0T9nTOb9nvw+/y0QtaTZLeCjiXXiUa5g+qK+XQVey8xSw9ulZfsGX gnFM50k8DovjWVA+nEdGBDPovKJ6o0uhYUSsMbvnANHyuOu7h1nUxknYpIPwPZ42 tRZscbp9Yd7Cda+ZcUO9VurMauZchCbmBqRmp48= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=4I5kwX4NXW GOeGrgQeqdf5gHUyQ=; b=a9UhKKGhZ1dmJWVt29YB7erj/z32TLwtBNVPl2Lwwz 2kAYM1shiCgq8bWLtezHiDwps5q80oYIh8xoOBNyFMWEieY8hVaswWM10DQN2ui3 Wo0+t2ApWUfivRePh6WuqeI+COPMRFkj7hzGbHcu0iSwmlIAzy4HcvW+Tmbq388g c= Received: (qmail 18505 invoked by alias); 3 May 2014 10:48:40 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 18495 invoked by uid 89); 3 May 2014 10:48:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, SPF_NEUTRAL autolearn=no version=3.3.2 X-HELO: popelka.ms.mff.cuni.cz Date: Sat, 3 May 2014 12:48:31 +0200 From: =?utf-8?B?T25kxZllaiBCw61sa2E=?= To: Torvald Riegel Cc: Carlos O'Donell , Andi Kleen , libc-alpha@sourceware.org Subject: [PATCH] Converted benchmark to benchtest. Message-ID: <20140503104831.GA16118@domone.podge> References: <1395789863-5026-1-git-send-email-andi@firstfloor.org> <1397248605.10643.18269.camel@triegel.csb> <53497694.4040901@redhat.com> <20140412194007.GA1284@domone.podge> <1397402907.10643.19303.camel@triegel.csb> <534B8B38.8090402@redhat.com> <8761m9iekn.fsf@tassilo.jf.intel.com> <87mwfifiks.fsf@tassilo.jf.intel.com> <53603208.8060205@redhat.com> <1399033983.32485.5900.camel@triegel.csb> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1399033983.32485.5900.camel@triegel.csb> User-Agent: Mutt/1.5.20 (2009-06-14) X-DH-Original-To: glibc@patchwork.siddhesh.in On Fri, May 02, 2014 at 02:33:03PM +0200, Torvald Riegel wrote: > On Tue, 2014-04-29 at 19:13 -0400, Carlos O'Donell wrote: > > On 04/18/2014 05:12 PM, Andi Kleen wrote: > > > Andi Kleen writes: > > > > > >> "Carlos O'Donell" writes: > > >>> > > >>> That's right. I'd like to see the whatever code was used to benchmark > > >>> the performance submitted as a microbenchmark so I can run it myself > > >>> and verify. Again, it's not that I don't trust Andi, but an objective > > >>> evaluation is always going to be the best defense for these changes. > > >> > > >> Here is the code I used: > > > > > > Any comments now? Is the code ok to commit now? > > I've seen a few minor issues (see reply to patch). > > > > If yes please someone with access rights commit it. > > > > Sorry, April is busy. > > > > Torvlad, Have you had a chance to look at this? > > Someone needs to put this benchmark into benchtest form. (Otherwise, we > won't fulfill your requirement of having microbenchmarks...) > Here is benchtest conversion. It really does not add new data so can you say now that dropping assembly really makes no difference? > We could also consider adding a scalability benchtest for the rwlock, > and using the single thread data from it to compare. That's on my list > of things to do, but haven't gotten to this yet. Its nice to have but orthogonal on proposed change, so it should not block this patch * benchtests/Makefile (bench-pthread): Add rwlock. * benchtests/bench-rwlock.c: New file. --- benchtests/Makefile | 2 +- benchtests/bench-rwlock.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 benchtests/bench-rwlock.c diff --git a/benchtests/Makefile b/benchtests/Makefile index a0954cd..67fa507 100644 --- a/benchtests/Makefile +++ b/benchtests/Makefile @@ -25,7 +25,7 @@ include ../Makeconfig bench-math := acos acosh asin asinh atan atanh cos cosh exp exp2 ffs ffsll \ log log2 modf pow rint sin sincos sinh sqrt tan tanh -bench-pthread := pthread_once +bench-pthread := pthread_once rwlock bench := $(bench-math) $(bench-pthread) diff --git a/benchtests/bench-rwlock.c b/benchtests/bench-rwlock.c new file mode 100644 index 0000000..cc68f97 --- /dev/null +++ b/benchtests/bench-rwlock.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include "bench-timing.h" + + +pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER; + +#define ITER 100 + +int +main (void) +{ + int i, j; + + timing_t start, end, cur; + for (j = 0; j < 50; j++) + { + pthread_rwlock_rdlock (&rwlock); + pthread_rwlock_unlock (&rwlock); + + pthread_rwlock_wrlock (&rwlock); + pthread_rwlock_unlock (&rwlock); + + TIMING_NOW (start); + for (i = 0; i < ITER; i++) + { + pthread_rwlock_rdlock (&rwlock); + pthread_rwlock_unlock (&rwlock); + } + TIMING_NOW (end); + + if (j > 0) + { + printf ("\nrdlock avg"); + TIMING_DIFF (cur, start, end); + TIMING_PRINT_MEAN ((double) cur, (double) ITER); + } + + TIMING_NOW (start); + for (i = 0; i < ITER; i++) + { + pthread_rwlock_wrlock (&rwlock); + pthread_rwlock_unlock (&rwlock); + } + TIMING_NOW (end); + + if (j > 0) + { + printf ("\nwrlock avg"); + TIMING_DIFF (cur, start, end); + TIMING_PRINT_MEAN ((double) cur, (double) ITER); + } + } + return 0; +}