Skip site navigation (1) Skip section navigation (2)

Re: futex results with dbt-3

From: Manfred Spraul <manfred(at)colorfullife(dot)com>
To: neilc(at)samurai(dot)com
Cc: markw(at)osdl(dot)org, pgsql-performance(at)postgresql(dot)org
Subject: Re: futex results with dbt-3
Date: 2004-10-17 07:39:33
Message-ID: 417221B5.1050704@colorfullife.com (view raw or flat)
Thread:
Lists: pgsql-performance
Neil wrote:

>. In any case, the "futex patch"
>uses the Linux 2.6 futex API to implement PostgreSQL spinlocks. 
>
Has anyone tried to replace the whole lwlock implementation with 
pthread_rwlock? At least for Linux with recent glibcs, pthread_rwlock is 
implemented with futexes, i.e. we would get a fast lock handling without 
os specific hacks. Perhaps other os contain user space pthread locks, too.
Attached is an old patch. I tested it on an uniprocessor system a year 
ago and it didn't provide much difference, but perhaps the scalability 
is better. You'll have to add -lpthread to the library list for linking.

Regarding Neil's patch:

>! /*
>!  * XXX: is there a more efficient way to write this? Perhaps using
>!  * decl...?
>!  */
>! static __inline__ slock_t
>! atomic_dec(volatile slock_t *ptr)
>! {
>! 	slock_t prev = -1;
>! 
>! 	__asm__ __volatile__(
>! 		"	lock		\n"
>! 		"	xadd %0,%1	\n"
>! 		:"=q"(prev)
>! 		:"m"(*ptr), "0"(prev)
>! 		:"memory", "cc");
>! 
>! 	return prev;
>! }
>
xadd is not supported by original 80386 cpus, it was added for 80486 
cpus. There is no instruction in the 80386 cpu that allows to atomically 
decrement and retrieve the old value of an integer. The only option are 
atomic_dec_test_zero or atomic_dec_test_negative - that can be 
implemented by looking at the sign/zero flag. Depending on what you want 
this may be enough. Or make the futex code conditional for > 80386 cpus.

--
    Manfred

Attachment: patch-pthread-force
Description: text/plain (4.7 KB)

Responses

pgsql-performance by date

Next:From: simonDate: 2004-10-17 19:40:01
Subject: Re: Getting rid of AtEOXact Buffers (was Re: [Testperf-general] Re: [PERFORM] First set of OSDL Shared Memscalability results, some wierdness ...)
Previous:From: Josh BerkusDate: 2004-10-16 21:36:45
Subject: Re: Getting rid of AtEOXact_Buffers (was Re: [Testperf-general] Re: [PERFORM] First set of OSDL Shared Memscalability results, some wierdness ...)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group