Re: On the need for a snapshot in exec_bind_message() - Mailing list pgsql-hackers

From Andres Freund
Subject Re: On the need for a snapshot in exec_bind_message()
Date
Msg-id 20180905203321.6oinlusgj26npshr@alap3.anarazel.de
Whole thread Raw
In response to On the need for a snapshot in exec_bind_message()  (Daniel Wood <hexexpert@comcast.net>)
List pgsql-hackers
Hi,

On 2018-09-05 12:31:04 -0700, Daniel Wood wrote:
> NOTE:
> 
> In GetSnapshotData because pgxact, is declared volatile, the compiler will not reduce the following two IF tests into
asingle test:
 
> 
> 
>     if (pgxact->vacuumFlags & PROC_IN_LOGICAL_DECODING)
>         continue;
> 
> 
>     if (pgxact->vacuumFlags & PROC_IN_VACUUM)
>         continue;
> 
> 
> You can reduce the code path in the inner loop by coding this as:
> 
>     if (pgxact->vacuumFlags & (PROC_IN_LOGICAL_DECODING|PROC_IN_VACUUM))
>         continue;
> 
> 
> I'm still working on quantifying any gain.  Note it isn't just one L1 cache
> 
> fetch and one conditional branch eliminated.  Due to the update frequency of the pgxact cache line, for single
statementTXN's, there are a certain number of full cache misses, due to invalidation, that occurs when given pgxact is
updatedbetween the first fetch of vacuumFlags and the 2nd fetch.
 

These two obviously could be combined, but I think we should just get
rid of the volatiles. With a small bit of work they shouldn't be
required anymore these days.

Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: pgsql: Clean up after TAP tests in oid2name and vacuumlo.
Next
From: Alexander Korotkov
Date:
Subject: Re: Bug in ginRedoRecompress that causes opaque data on page to be overrun