]> granicus.if.org Git - postgresql/commitdiff
Combine two flag tests in GetSnapshotData().
authorAndres Freund <andres@anarazel.de>
Sat, 10 Nov 2018 04:43:56 +0000 (20:43 -0800)
committerAndres Freund <andres@anarazel.de>
Sat, 10 Nov 2018 04:43:56 +0000 (20:43 -0800)
Previously the code checked PROC_IN_LOGICAL_DECODING and
PROC_IN_VACUUM separately. As the relevant variable is marked as
volatile, the compiler cannot combine the two tests.  As
GetSnapshotData() is pretty hot in a number of workloads, it's
worthwhile to fix that.

It'd also be a good idea to get rid of the volatiles altogether. But
for one that's a larger patch, and for another, the code after this
change still seems at least as easy to read as before.

Author: Andres Freund
Discussion: https://postgr.es/m/20181005172955.wyjb4fzcdzqtaxjq@alap3.anarazel.de

src/backend/storage/ipc/procarray.c

index 908f62d37e271e6fb94459fc64dce5436bb5e754..c861f3e17f92c7298e568ab369407a4ee2daee12 100644 (file)
@@ -1589,14 +1589,11 @@ GetSnapshotData(Snapshot snapshot)
                        TransactionId xid;
 
                        /*
-                        * Backend is doing logical decoding which manages xmin
-                        * separately, check below.
+                        * Skip over backends doing logical decoding which manages xmin
+                        * separately (check below) and ones running LAZY VACUUM.
                         */
-                       if (pgxact->vacuumFlags & PROC_IN_LOGICAL_DECODING)
-                               continue;
-
-                       /* Ignore procs running LAZY VACUUM */
-                       if (pgxact->vacuumFlags & PROC_IN_VACUUM)
+                       if (pgxact->vacuumFlags &
+                               (PROC_IN_LOGICAL_DECODING | PROC_IN_VACUUM))
                                continue;
 
                        /* Update globalxmin to be the smallest valid xmin */