From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Sokolov Yura <funny(dot)falcon(at)postgrespro(dot)ru>, Robert Haas <robertmhaas(at)gmail(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Jesper Pedersen <jesper(dot)pedersen(at)redhat(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Fix performance of generic atomics |
Date: | 2017-09-06 19:27:46 |
Message-ID: | 20170906192745.inngysckotjeznho@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2017-09-06 15:25:20 -0400, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
> > On 2017-09-06 15:12:13 -0400, Tom Lane wrote:
> >> It looks to me like two of the three implementations promise no such
> >> thing.
>
> > They're volatile vars, so why not?
>
> Yeah, but so are the caller's variables. That is, in
>
> pg_atomic_exchange_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 xchg_)
> {
> uint64 old;
> old = ptr->value;
>
> ISTM that the compiler is required to actually fetch ptr->value, not
> rely on some previous read of it. I do not think that (the first
> version of) pg_atomic_read_u64_impl is adding any guarantee that wasn't
> there already.
>
> >> Even if they somehow do, it hardly matters given that the cmpxchg loop
> >> would be self-correcting.
>
> > Well, in this one instance maybe, hardly in others.
>
> All the functions involved use nigh-identical cmpxchg loops.
>
> > What are you suggesting as an alternative?
>
> I think we can just use "old = ptr->value" to set up for the cmpxchg
> loop in every generic.h function that uses such a loop.
I think we might have been talking past each other - I thought you were
talking about changing the pg_atomic_read_u64_impl implementation for
external users.
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2017-09-06 19:32:29 | Re: why not parallel seq scan for slow functions |
Previous Message | Tom Lane | 2017-09-06 19:25:20 | Re: Fix performance of generic atomics |