Replace known_assigned_xids_lck by memory barrier
Michail Nikolaev <michail.nikolaev@gmail.com>
From: Michail Nikolaev <michail.nikolaev@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2023-03-19T09:43:43Z
Lists: pgsql-hackers
Attachments
- v2-0001-Removes-known_assigned_xids_lck-using-the-write-m.patch (application/x-patch) patch v2-0001
Hello everyone and Tom. Tom, this is about your idea (1) from 2010 to replace spinlock with a memory barrier in a known assignment xids machinery. It was mentioned by you again in (2) and in (3) we have decided to extract this change into a separate commitfest entry. So, creating it here with a rebased version of (4). In a nutshell: KnownAssignedXids as well as the head/tail pointers are modified only by the startup process, so spinlock is used to ensure that updates of the array and head/tail pointers are seen in a correct order. It is enough to pass the barrier after writing to the array (but before updating the pointers) to achieve the same result. Best regards. [1]: https://github.com/postgres/postgres/commit/2871b4618af1acc85665eec0912c48f8341504c4#diff-8879f0173be303070ab7931db7c757c96796d84402640b9e386a4150ed97b179R2408-R2412 [2]: https://www.postgresql.org/message-id/flat/1249332.1668553589%40sss.pgh.pa.us#19d00eb435340f5c5455e3bf259eccc8 [3]: https://www.postgresql.org/message-id/flat/1225350.1669757944%40sss.pgh.pa.us#23ca1956e694910fd7795a514a3bc79f [4]: https://www.postgresql.org/message-id/flat/CANtu0oiPoSdQsjRd6Red5WMHi1E83d2%2B-bM9J6dtWR3c5Tap9g%40mail.gmail.com#cc4827dee902978f93278732435e8521
Commits
-
Replace known_assigned_xids_lck with memory barriers.
- 119c23eb9819 17.0 landed
-
Replace the KnownAssignedXids hash table with a sorted-array data structure,
- 2871b4618af1 9.0.0 cited