Re: Changing WAL Header to reduce contention during ReserveXLogInsertLocation()

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Changing WAL Header to reduce contention during ReserveXLogInsertLocation()
Date: 2018-07-09 15:57:29
Message-ID: CANP8+jLUm8=irmx5NF3CVx=pai6Fs3=JkPiEeZgtMV+F3WzhvQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 9 July 2018 at 14:49, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
> On 03/04/18 19:20, Andres Freund wrote:
>>
>> On 2018-04-03 09:56:24 -0400, Tom Lane wrote:
>>>
>>> Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
>>>>
>>>> But let's go back to why we're considering this. The idea was to
>>>> optimize this block:
>>>> ...
>>>> One trick that we could do is to replace that with a 128-bit atomic
>>>> compare-and-swap instruction. Modern 64-bit Intel systems have that,
>>>> it's called CMPXCHG16B. Don't know about other architectures. An atomic
>>>> fetch-and-add, as envisioned in the comment above, would presumably be
>>>> better, but I suspect that a compare-and-swap would be good enough to
>>>> move the bottleneck elsewhere again.
>>>
>>>
>>> +1 for taking a look at that. A bit of experimentation shows that
>>> recent gcc and clang can generate that instruction using
>>> __sync_bool_compare_and_swap or __sync_val_compare_and_swap
>>> on an __int128 value.
>>
>>
>> The problem will presumably be that early opteron AMD64s lacked that
>> instruction. I'm not sure which distributions still target them (windows
>> dropped support a few years ago), but we should make sure that neither
>> the necessary dispatch code isn't going to add so much overhead it's
>> eating into our margin, nor that the generated code SIGILLs on such
>> platforms.
>
>
> Yeah.
>
> I'll mark this as "returned with feedback" in the commitfest. The way
> forward is to test if we can get the same performance benefit from switching
> to CMPXCHG16B, and keep the WAL format unchanged. If not, then we can
> continue discussing the WAL format and the tradeoffs with xl_prev, but let's
> take the easy way out if we can.

Agreed. Were you working on this? Or was anybody else?

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2018-07-09 15:59:48 Re: Changing WAL Header to reduce contention during ReserveXLogInsertLocation()
Previous Message Tom Lane 2018-07-09 15:34:26 Re: cannot restore schema with is not distinct from on hstore since PG 9.6.8