From 0d76b60db4684d3487223b003833828fe9655fe2 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 16 Dec 2011 21:44:26 -0500 Subject: Various micro-optimizations for GetSnapshopData(). Heikki Linnakangas had the idea of rearranging GetSnapshotData to avoid checking for sub-XIDs when no top-level XID is present. This patch does that plus further a bit of further, related rearrangement. Benchmarking show a significant improvement on unlogged tables at higher concurrency levels, and mostly indifferent result on permanent tables (which are presumably bottlenecked elsewhere). Most of the benefit seems to come from using the new NormalTransactionIdPrecedes() macro rather than the function call TransactionIdPrecedes(). --- src/include/access/transam.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/include/access/transam.h') diff --git a/src/include/access/transam.h b/src/include/access/transam.h index c038fd9a52d..3ac1403c525 100644 --- a/src/include/access/transam.h +++ b/src/include/access/transam.h @@ -58,6 +58,10 @@ (dest)--; \ } while ((dest) < FirstNormalTransactionId) +/* compare two XIDs already known to be normal; this is a macro for speed */ +#define NormalTransactionIdPrecedes(id1, id2) \ + (AssertMacro(TransactionIdIsNormal(id1) && TransactionIdIsNormal(id2)), \ + (int32) ((id1) - (id2)) < 0) /* ---------- * Object ID (OID) zero is InvalidOid. -- cgit v1.2.3