| From: | Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: convert various variables to atomics |
| Date: | 2026-09-11 14:43:22 |
| Message-ID: | 55e6a615-ec9d-4a57-8f36-7fbd1674da2c@postgrespro.ru |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
08.09.2026 22:49, Nathan Bossart пишет:
> On Tue, Sep 08, 2026 at 12:00:47PM -0500, Nathan Bossart wrote:
>> * v2-0001: We are changing a variable from signed to unsigned, but the code
>> goes out of its way to avoid negative values and signed integer overflow,
>> so I don't think there are any real problems here. The only atomic
>> arithmetic operation is in SICleanupQueue() where we subtract
>> MSGNUMWRAPAROUND, which IIUC should never produce a negative value. That
>> being said, I don't think it would be too disruptive to switch all relevant
>> variables to uint32 as a prerequisite patch. I don't see any particular
>> reason for those variables to be signed, anyway.
>
> v3-0001 is the prerequisite patch. This requires some new clamping logic
> in SICleanupQueue() for minsig and lowbound, since the subtractions can
> produce negative values. I believe this retains the existing behavior, but
> need to double-check.
Personally, I don't like current implementation of
pg_atomic_read_membarrier_u32 because it writes into shared variable.
That is why in [1] (thread [2]) I used explicit pg_memory_barrier before
and pg_read_barrier after reading segP->maxMsgNum. (pg_memory_barrier
writes onto stack - process's private memory, and pg_read_barrier does
nothing on x86_64).
[1]
https://www.postgresql.org/message-id/attachment/174633/v3-0001-sinvaladt.c-use-atomic-operations-on-maxMsgNum.patch
[2]
https://www.postgresql.org/message-id/flat/30aa0030-f694-44ef-a19d-6ef7ddb69374%40postgrespro.ru
--
regards
Yura Sokolov aka funny-falcon
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Greg Burd | 2026-09-11 14:47:56 | Re: [PATCH] Batched clock sweep to reduce cross-socket atomic contention |
| Previous Message | Thom Brown | 2026-09-11 14:41:54 | Re: Logical Implication |