This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Converted benchmark to benchtest.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Torvald Riegel <triegel at redhat dot com>
- Cc: Carlos O'Donell <carlos at redhat dot com>, Andi Kleen <andi at firstfloor dot org>, libc-alpha at sourceware dot org
- Date: Sat, 3 May 2014 12:48:31 +0200
- Subject: [PATCH] Converted benchmark to benchtest.
- Authentication-results: sourceware.org; auth=none
- References: <1395789863-5026-1-git-send-email-andi at firstfloor dot org> <1397248605 dot 10643 dot 18269 dot camel at triegel dot csb> <53497694 dot 4040901 at redhat dot com> <20140412194007 dot GA1284 at domone dot podge> <1397402907 dot 10643 dot 19303 dot camel at triegel dot csb> <534B8B38 dot 8090402 at redhat dot com> <8761m9iekn dot fsf at tassilo dot jf dot intel dot com> <87mwfifiks dot fsf at tassilo dot jf dot intel dot com> <53603208 dot 8060205 at redhat dot com> <1399033983 dot 32485 dot 5900 dot camel at triegel dot csb>
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 <andi@firstfloor.org> writes:
> > >
> > >> "Carlos O'Donell" <carlos@redhat.com> 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 <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#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;
+}
--
1.8.4.rc3