This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Updated rwlock-in-C patchkit
- From: Andi Kleen <andi at firstfloor dot org>
- To: "Carlos O'Donell" <carlos at redhat dot com>
- Cc: Torvald Riegel <triegel at redhat dot com>, OndÅej BÃlka <neleai at seznam dot cz>, libc-alpha at sourceware dot org
- Date: Wed, 16 Apr 2014 06:33:44 -0700
- Subject: Re: Updated rwlock-in-C patchkit
- 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>
"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:
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;
#define ITER 100
main()
{
int i, j;
for (j = 0; j < 50; j++) {
pthread_rwlock_rdlock(&rwlock);
pthread_rwlock_unlock(&rwlock);
pthread_rwlock_wrlock(&rwlock);
pthread_rwlock_unlock(&rwlock);
uint64_t start = __builtin_ia32_rdtsc();
for (i = 0; i < ITER; i++) {
pthread_rwlock_rdlock(&rwlock);
pthread_rwlock_unlock(&rwlock);
}
uint64_t end = __builtin_ia32_rdtsc();
if (j > 0)
printf("rdlock avg %.f\n", (end-start)/(float)ITER);
start = __builtin_ia32_rdtsc();
for (i = 0; i < ITER; i++) {
pthread_rwlock_wrlock(&rwlock);
pthread_rwlock_unlock(&rwlock);
}
end = __builtin_ia32_rdtsc();
if (j > 0)
printf("wrlock avg %.f\n", (end-start)/(float)ITER);
}
return 0;
}