Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UmIUU-00011p-EA for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Jun 2013 06:55:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UmIUT-0005j1-Tw for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Jun 2013 06:55:37 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UmIUS-0005iI-Jk for pgsql-hackers@postgresql.org; Tue, 11 Jun 2013 06:55:36 +0000 Received: from tyrone.bluegap.ch ([5.9.120.207] helo=klepario.bluegap.ch) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UmIUP-0003yb-V1 for pgsql-hackers@postgresql.org; Tue, 11 Jun 2013 06:55:36 +0000 Received: from [10.80.16.200] ([::ffff:31.24.12.47]) (AUTH: LOGIN markus@bluegap.ch, TLS: TLSv1/SSLv3,256bits,CAMELLIA256-SHA) by klepario.bluegap.ch with ESMTPSA; Tue, 11 Jun 2013 08:54:56 +0200 id 000000000119E477.51B6C9C0.00006383 Message-ID: <51B6C97B.1070000@bluegap.ch> Date: Tue, 11 Jun 2013 08:53:47 +0200 From: Markus Wanner User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: Ants Aasma CC: PostgreSQL-development Subject: Re: Proposal for CSN based snapshots References: <51B1CB35.4050406@bluegap.ch> In-Reply-To: X-Enigmail-Version: 1.4.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.1 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Ants, the more I think about this, the more I start to like it. On 06/07/2013 02:50 PM, Ants Aasma wrote: > On Fri, Jun 7, 2013 at 2:59 PM, Markus Wanner wrote: >> Agreed. Postgres-R uses a CommitOrderId, which is very similar in >> concept, for example. > > Do you think having this snapshot scheme would be helpful for Postgres-R? Yeah, it could help to reduce patch size, after a rewrite to use such a CSN. >> Or why do you need to tell apart aborted from in-progress transactions >> by CSN? > > I need to detect aborted transactions so they can be discared during > the eviction process, otherwise the sparse array will fill up. They > could also be filtered out by cross-referencing uncommitted slots with > the procarray. Having the abort case do some additional work to make > xid assigment cheaper looks like a good tradeoff. I see. >>> Sparse buffer needs to be at least big enough to fit CSN slots for the >>> xids of all active transactions and non-overflowed subtransactions. At >>> the current level PGPROC_MAX_CACHED_SUBXIDS=64, the minimum comes out >>> at 16 bytes * (64 + 1) slots * 100 = backends = 101.6KB per buffer, >>> or 203KB total in the default configuration. >> >> A CSN is 8 bytes, the XID 4, resulting in 12 bytes per slot. So I guess >> the given 16 bytes includes alignment to 8 byte boundaries. Sounds good. > > 8 byte alignment for CSNs is needed for atomic if not something else. Oh, right, atomic writes. > I think the size could be cut in half by using a base value for CSNs > if we assume that no xid is active for longer than 2B transactions as > is currently the case. I didn't want to include the complication in > the first iteration, so I didn't verify if that would have any > gotchas. In Postgres-R, I effectively used a 32-bit order id which wraps around. In this case, I guess adjusting the base value will get tricky. Wrapping could probably be used as well, instead. > The number of times each cache line can be invalidated is > bounded by 8. Hm.. good point. Regards Markus Wanner -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers