From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Atomic operations within spinlocks |
Date: | 2020-06-04 19:06:45 |
Message-ID: | 20200604190645.xumymtlefvqgdhfr@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On 2020-06-04 14:50:40 -0400, Tom Lane wrote:
> Actually ... we could probably use this design with a uint32 counter
> as well, on machines where the 64-bit operations would be slow.
On skylake-x even a 32bit [i]div is still 26 cycles. That's more than an
atomic operation 18 cycles.
> 2. The computed completePasses value would go backwards. I bet
> that wouldn't matter too much either, or at least we could teach
> BgBufferSync to cope. (I notice the comments therein suggest that
> it is already designed to cope with completePasses wrapping around,
> so maybe nothing needs to be done.)
If we're not concerned about that, then we can remove the
atomic-inside-spinlock, I think. The only reason for that right now is
to avoid assuming a wrong pass number.
I don't think completePasses wrapping around is comparable in frequency
to wrapping around nextVictimBuffer. It's not really worth worrying
about bgwriter wrongly assuming it lapped the clock sweep once ever
UINT32_MAX * NBuffers ticks, but there being a risk every NBuffers seems
worth worrying about.
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-06-04 19:07:34 | Re: Atomic operations within spinlocks |
Previous Message | Andres Freund | 2020-06-04 18:55:25 | Re: Atomic operations within spinlocks |