Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id A653C9FE16E for ; Thu, 14 Jun 2012 18:58:29 -0300 (ADT) Received: from moutng.kundenserver.de ([212.227.126.186]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SfI3g-0004t5-EG for pgsql-hackers@postgresql.org; Thu, 14 Jun 2012 21:58:29 +0000 Received: from awork2.localnet (p5DDC6437.dip.t-dialin.net [93.220.100.55]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0MXVkk-1SSaB84BYk-00WZIn; Thu, 14 Jun 2012 23:58:13 +0200 From: Andres Freund Organization: 2ndquadrant.com To: pgsql-hackers@postgresql.org Subject: Re: WAL format changes Date: Thu, 14 Jun 2012 23:58:12 +0200 User-Agent: KMail/1.13.7 (Linux/3.4.0-andres; KDE/4.8.3; x86_64; ; ) Cc: Heikki Linnakangas References: <4FDA5136.6080206@enterprisedb.com> In-Reply-To: <4FDA5136.6080206@enterprisedb.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201206142358.12431.andres@2ndquadrant.com> X-Provags-ID: V02:K0:KuPFs0wn4UJvREwdAfZViotkTaqSZ7ER68OOCICbHuy zFPVTLaE0/snS7tMFwdy97Xk/9RjbGwCPG+DND+NUFshEjJY/l rH2l3m+oEjBsGrBvaqfd3zZlIQcEAUXhf+uf+z6jVFwm33cJ57 iE39KnPVssxdV7OhqO+UdPeIt23PkfPsJbMRFyXHMMIaQA8iHr vcAL8/V0/3I8rKSQkyZsjbYe1tjkCNB+vNqhuhmE3LU6+LNCwb Y/EY2yDrlSIEKKIxg1KCg0LSFgpMBOPPRctXsX75dQMSn/0ryA 5U59EHto+7YKN6FA1R3+iZNP45i5rfzvgGMWeWEfPgcoZ35dtD YcarElYF2iTtGTLj4Rdqz0hkihtplOSKvH7UwZKQzKxnOV44D1 vC1QW/sjgpzbA== X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/690 X-Sequence-Number: 209530 On Thursday, June 14, 2012 11:01:42 PM Heikki Linnakangas wrote: > As I threatened earlier > (http://archives.postgresql.org/message-id/4FD0B1AB.3090405@enterprisedb.co > m), here are three patches that change the WAL format. The goal is to > change the format so that when you're inserting a WAL record of a given > size, you know exactly how much space it requires in the WAL. > > 1. Use a 64-bit segment number, instead of the log/seg combination. And > don't waste the last segment on each logical 4 GB log file. The concept > of a "logical log file" is now completely gone. XLogRecPtr is unchanged, > but it should now be understood as a plain 64-bit value, just split into > two 32-bit integers for historical reasons. On disk, this means that > there will be log files ending in FF, those were skipped before. Whats the reason for keeping that awkward split now? There aren't that many users of xlogid/xcrecoff and many of those would be better served by using helper macros. API compatibility isn't a great argument either as code manually playing around with those needs to be checked anyway. I think there might be some code around that does XLogRecPtr addition manuall and such. > 2. Always include the xl_rem_len field, used for continuation records, > in the xlog page header. A continuation log record only contained that > one field, it's now included straight in the page header, so the concept > of a continuation record doesn't exist anymore. Because of alignment, > this wastes 4 bytes on every page that contains continued data from a > previous record, and 8 bytes on pages that don't. That's not very much, > and the next step will buy that back: > > 3. Allow WAL record header to be split across pages. Per Tom's > suggestion, move xl_tot_len to be the first field in XLogRecord, so that > even if the header is split, xl_tot_len is always on the first page. > xl_crc is moved to be the last field, and xl_prev is the second to last. > This has the advantage that you can calculate the CRC for all the other > fields before acquiring WALInsertLock. For xl_prev, you need to know > where exactly the record is inserted, so it's handy that it's the last > field before CRC. This patch doesn't try to take advantage of that, > however, and I'm not sure if that makes any difference once I finish the > patch to make XLogInsert scale better, which is the ultimate goal of all > this. > > Those are the three patches I'd like to get committed in this > commitfest. To see where all this is leading to, I've included a rough > WIP version of the XLogInsert scaling patch. This version is quite > different from the one I posted in spring, it takes advantage of the WAL > format changes, and I'm also experimenting with a different method of > tracking how far each WAL insertion has progressed. But more on that later. > > (Note to self: remember to bump XLOG_PAGE_MAGIC) Will review. Andres -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services