Re: [HACKERS] Fix performance of generic atomics - Mailing list pgsql-hackers

From Robert Haas
Subject Re: [HACKERS] Fix performance of generic atomics
Date
Msg-id CA+TgmoY36Rbp5W_1JjFZj1wGhUNUOfgT3qsApEpKK2yKmgdhUw@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] Fix performance of generic atomics  (Sokolov Yura <funny.falcon@postgrespro.ru>)
Responses Re: [HACKERS] Fix performance of generic atomics
List pgsql-hackers
On Wed, Sep 6, 2017 at 9:42 AM, Sokolov Yura
<funny.falcon@postgrespro.ru> wrote:
> Yes, you're right.
>
> But I think, generic version still should be "fixed".
> If generic version is not reached on any platform, then why it is kept?
> If it is reached somewhere, then it should be improved.

This seems like a pretty sound argument to me.  I think Tom's probably
right that the changes in generic-gcc.h are the important ones, but
I'm not sure that's an argument against patching generics.h.  Given
that pg_atomic_compare_exchange_u32_impl is defined to update *old
there seems to be no reason to call pg_atomic_read_u32_impl every time
through the loop.  Whether doing so hurts performance in practice is
likely to depend on a bunch of stuff, but we don't normally refuse to
remove unnecessary code on the grounds that it will rarely be reached.
Given that CPUs are weird, it's possible that there is some system
where throwing an extra read of a value we already have into the loop
works out to a win, but in the absence of evidence I'm reluctant to
presume it.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] PoC plpgsql - possibility to force custom or generic plan
Next
From: Jacob Champion
Date:
Subject: Re: [HACKERS] [PATCH] Assert that the correct locks are held whencalling PageGetLSN()