Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 82E3E6330C2 for ; Wed, 18 Mar 2009 04:48:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 74011-03-7 for ; Wed, 18 Mar 2009 04:48:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail137144.authsmtp.net (outmail137144.authsmtp.net [62.13.137.144]) by mail.postgresql.org (Postfix) with ESMTP id CE133632723 for ; Wed, 18 Mar 2009 04:48:44 -0300 (ADT) Received: from mail-c193.authsmtp.com (mail-c193.authsmtp.com [62.13.128.118]) by punt9.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id n2I7maJB017054; Wed, 18 Mar 2009 07:48:36 GMT Received: from [192.168.0.2] (85-211-223-92.dyn.gotadsl.co.uk [85.211.223.92]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id n2I7mZ4Q020974; Wed, 18 Mar 2009 07:48:35 GMT Subject: Re: Proposal of tunable fix for scalability of 8.4 From: Simon Riggs To: Tom Lane Cc: Heikki Linnakangas , Robert Haas , Scott Carey , Greg Smith , "Jignesh K. Shah" , Kevin Grittner , "pgsql-performance@postgresql.org" In-Reply-To: <5077.1237046989@sss.pgh.pa.us> References: <603c8f070903121829r31cf1472ha9876e5c480a542e@mail.gmail.com> <12292.1236964604@sss.pgh.pa.us> <49BB699D.1070809@enterprisedb.com> <5077.1237046989@sss.pgh.pa.us> Content-Type: text/plain Date: Wed, 18 Mar 2009 07:48:38 +0000 Message-Id: <1237362518.3953.181.camel@ebony.2ndQuadrant> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: 2fe58aff-1391-11de-8a51-002264978518 X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksafhtFaQ1bYFhD HGQLW11EUFp7XWt/ aAwfZQBDYEtPQQdo U1ZAQE1QEQdtHhxP WBxnVUQYc2RGen55 YkIsXXBYWgp4IxN4 Sh8CQ3AHZm5hdWEe BBVFf1JRcR5Kfh1H bFR2U3sIYG1JBC9q VzwLEgofGg96HWxt WAYVKkkbRQ4MEHYg WhYLFzEiVUMEV209 KAZuMVUVGE8bM0Ez LUppXlxQY1lOYiwg X-Authentic-SMTP: 61633235383639.pelican.dmpriest.net.uk:1378/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200903/241 X-Sequence-Number: 33163 On Sat, 2009-03-14 at 12:09 -0400, Tom Lane wrote: > Heikki Linnakangas writes: > > WALInsertLock is also quite high on Jignesh's list. That I've seen > > become the bottleneck on other tests too. > > 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 ... > obtain WALInsertLock > identify WAL start address of my record, advance insert pointer > past record end > *release* WALInsertLock > 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). > > Now the fly in the ointment is that there would need to be some way to > ensure that we didn't write data out to disk until it was valid; in > particular how do we implement a request to flush WAL up to a particular > LSN value, when maybe some of the records before that haven't been fully > transferred into the buffers yet? The best idea I've thought of so far > is shared/exclusive locks on the individual WAL buffer pages, with the > rather unusual behavior that writers of the page would take shared lock > and only the reader (he who has to dump to disk) would take exclusive > lock. But maybe there's a better way. Currently I don't believe that > dumping a WAL buffer (WALWriteLock) blocks insertion of new WAL data, > and it would be nice to preserve that property. Yeh, that's just what we'd discussed previously: http://markmail.org/message/gectqy3yzvjs2hru#query:Reworking%20WAL% 20locking+page:1+mid:gectqy3yzvjs2hru+state:results Are you thinking of doing this for 8.4? :-) -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support