Re: Make HeapTupleSatisfiesMVCC more concurrent - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Make HeapTupleSatisfiesMVCC more concurrent
Date
Msg-id 32658.1439996100@sss.pgh.pa.us
Whole thread Raw
In response to Re: Make HeapTupleSatisfiesMVCC more concurrent  (Andres Freund <andres@anarazel.de>)
Responses Re: Make HeapTupleSatisfiesMVCC more concurrent  (Andres Freund <andres@anarazel.de>)
Re: Make HeapTupleSatisfiesMVCC more concurrent  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> On 2015-08-18 20:36:13 -0400, Tom Lane wrote:
>> I experimented with the attached patch, which replaces
>> HeapTupleSatisfiesMVCC's calls of TransactionIdIsInProgress with
>> XidInMVCCSnapshot, and then as a cross-check has all the "return false"
>> exits from XidInMVCCSnapshot assert !TransactionIdIsInProgress().

> I'm not sure about it, but it might be worthwhile to add a
> TransactionIdIsKnownCompleted() check before the more expensive parts of
> XidInMVCCSnapshot(). Neither the array search nor, much more so, the
> subtrans lookups are free.

Hmmm... the comment for TransactionIdIsKnownCompleted says it's to
short-circuit calls of TransactionIdIsInProgress, which we wouldn't be
doing anymore.  Maybe it's useful anyway but I'm not convinced.

In any case, the big picture here is that XidInMVCCSnapshot should on
average be looking at just about the same number of xids and subtrans ids
as TransactionIdIsInProgress does --- only the latter is looking at them
in the PGPROC array, so it needs a lock, and iterating over that data
structure is more complex than scanning an array too.

My own thought about reducing the cost of XidInMVCCSnapshot, if that
proves necessary, is that maybe it would be worth the trouble to sort the
arrays so we could use binary search.  That would increase the cost of
snapshot acquisition noticeably though.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Make HeapTupleSatisfiesMVCC more concurrent
Next
From: Andres Freund
Date:
Subject: Re: Make HeapTupleSatisfiesMVCC more concurrent