Top posting because my email client will mess up the inline:
Re: advance insert pointer.
I have no idea how complicated that advance part is as you allude to. But can this be done without a lock at all?
An atomic compare and exchange (or compare and set, etc) should do it. Although boundaries in buffers could make it a bit more complicated than that. Sounds potentially lockless to me. CompareAndSet - like atomics would prevent context switches entirely and generally work fabulous if the item that needs locking is itself an atomic value like a pointer or int. This is similar to, but lighter weight than, a spin lock.
From: Tom Lane [tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Saturday, March 14, 2009 9:09 AM
To: Heikki Linnakangas
Cc: Robert Haas; Scott Carey; Greg Smith; Jignesh K. Shah; Kevin Grittner; pgsql-performance(at)postgresql(dot)org
Subject: Re: [PERFORM] Proposal of tunable fix for scalability of 8.4
Yeah, that's been seen to be an issue before. I had the germ of an idea
about how to fix that:
... with no lock, determine size of WAL record ...
identify WAL start address of my record, advance insert pointer
past record end
without lock, copy record into the space just reserved
The idea here is to allow parallelization of the copying of data into
the buffers. The hold time on WALInsertLock would be very short. Maybe
it could even become a spinlock, though I'm not sure, because the
"advance insert pointer" bit is more complicated than it looks (you have
to allow for the extra overhead when crossing a WAL page boundary).
In response to
pgsql-performance by date
|Next:||From: Jignesh K. Shah||Date: 2009-03-15 20:36:56|
|Subject: Re: Proposal of tunable fix for scalability of 8.4|
|Previous:||From: Matteo Beccati||Date: 2009-03-15 02:38:17|
|Subject: Re: Query performance over a large proportion of data|