Re: Improving connection scalability: GetSnapshotData() - Mailing list pgsql-hackers
From | David Rowley |
---|---|
Subject | Re: Improving connection scalability: GetSnapshotData() |
Date | |
Msg-id | CAApHDvr2a-1efkLmHp6Au3cKD8P2KN9D6SEGW8Njz2BkFCLgvg@mail.gmail.com Whole thread Raw |
In response to | Improving connection scalability: GetSnapshotData() (Andres Freund <andres@anarazel.de>) |
Responses |
Re: Improving connection scalability: GetSnapshotData()
|
List | pgsql-hackers |
Hi, Nice performance gains. On Sun, 1 Mar 2020 at 21:36, Andres Freund <andres@anarazel.de> wrote: > The series currently consists out of: > > 0001-0005: Fixes and assert improvements that are independent of the patch, but > are hit by the new code (see also separate thread). > > 0006: Move delayChkpt from PGXACT to PGPROC it's rarely checked & frequently modified > > 0007: WIP: Introduce abstraction layer for "is tuple invisible" tests. > > This is the most crucial piece. Instead of code directly using > RecentOldestXmin, there's a new set of functions for testing > whether an xid is visible (InvisibleToEveryoneTestXid() et al). > > Those function use new horizon boundaries computed as part of > GetSnapshotData(), and recompute an accurate boundary when the > tested xid falls inbetween. > > There's a bit more infrastructure needed - we need to limit how > often an accurate snapshot is computed. Probably to once per > snapshot? Or once per transaction? > > > To avoid issues with the lower boundary getting too old and > presenting a wraparound danger, I made all the xids be > FullTransactionIds. That imo is a good thing? > > > This patch currently breaks old_snapshot_threshold, as I've not > yet integrated it with the new functions. I think we can make the > old snapshot stuff a lot more precise with this - instead of > always triggering conflicts when a RecentGlobalXmin is too old, we > can do so only in the cases we actually remove a row. I ran out of > energy threading that through the heap_page_prune and > HeapTupleSatisfiesVacuum. > > > 0008: Move PGXACT->xmin back to PGPROC. > > Now that GetSnapshotData() doesn't access xmin anymore, we can > make it a normal field in PGPROC again. > > > 0009: Improve GetSnapshotData() performance by avoiding indirection for xid access. I've only looked at 0001-0009 so far. I'm not quite the expert in this area, so the review feels a bit superficial. Here's what I noted down during my pass. 0001 1. cant't -> can't * snapshot cant't change in the midst of a relcache build, so there's no 0002 2. I don't quite understand your change in UpdateSubscriptionRelState(). snap seems unused. Drilling down into SearchSysCacheCopy2, in SearchCatCacheMiss() the systable_beginscan() passes a NULL snapshot. the whole patch does this. I guess I don't understand why 0002 does this. 0004 3. This comment seems to have the line order swapped in bt_check_every_level /* * RecentGlobalXmin/B-Tree page deletion. * This assertion matches the one in index_getnext_tid(). See note on */ Assert(SnapshotSet()); 0006 4. Did you consider the location of 'delayChkpt' in PGPROC. Couldn't you slot it in somewhere it would fit in existing padding? 0007 5. GinPageIsRecyclable() has no comments at all. I know that ginvacuum.c is not exactly the modal citizen for function header comments, but likely this patch is no good reason to continue the trend. 6. The comment rearrangement in bt_check_every_level should be in the 0004 patch. 7. struct InvisibleToEveryoneState could do with some comments explaining the fields. 8. The header comment in GetOldestXminInt needs to be updated. It talks about "if rel = NULL and there are no transactions", but there's no parameter by that name now. Maybe the whole comment should be moved down to the external implementation of the function 9. I get the idea you don't intend to keep the debug message in InvisibleToEveryoneTestFullXid(), but if you do, then shouldn't it be using UINT64_FORMAT? 10. teh -> the * which is based on teh value computed when getting the current snapshot. 11. InvisibleToEveryoneCheckXid and InvisibleToEveryoneCheckFullXid seem to have their extern modifiers in the .c file. 0009 12. iare -> are * These iare separate from the main PGPROC array so that the most heavily 13. is -> are * accessed data is stored contiguously in memory in as few cache lines as 14. It doesn't seem to quite make sense to talk about "this proc" in: /* * TransactionId of top-level transaction currently being executed by this * proc, if running and XID is assigned; else InvalidTransactionId. * * Each PGPROC has a copy of its value in PGPROC.xidCopy. */ TransactionId *xids; maybe "this" can be replaced with "each" I will try to continue with the remaining patches soon. However, it would be good to get a more complete patchset. I feel there are quite a few XXX comments remaining for things you need to think about later, and ... it's getting late.
pgsql-hackers by date: