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 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
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 | Content-Type | Size |
---|---|---|
patch-pthread-force | text/plain | 4.7 KB |