This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Updated rwlock-in-C patchkit


"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;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]