| From: | Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com> |
|---|---|
| To: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
| Cc: | Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: POC: Unlocked path for GetSnapshotDataReuse |
| Date: | 2026-12-03 20:19:19 |
| Message-ID: | CAEze2WhmOW-LR==nY9y2xiix7J_nD_6WYThVvn-+JT_amXibqg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, 12 Oct 2026 at 11:23, Bertrand Drouvot
<bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
> === 1
>
> pg_atomic_read_membarrier_u64() is documented to return the current value when
> updates use operations with barrier semantics, while IncrementXactCompletionCount()
> uses pg_atomic_write_u64().
>
> IIUC, this is safe because the counter update is followed by the full barrier
> LWLockRelease(ProcArrayLock).
Correct.
> I could not find another place relying on such a
> pairing though: existing callers use barrier semantic writes.
>
> Worth documenting this explicitly?
Done.
> === 2
>
> As pg_atomic_read_membarrier_u64() is potentially more expensive than
> pg_atomic_read_u64() then, what about keeping pg_atomic_read_membarrier_u64()
> at xmin_installed, but using pg_atomic_read_u64() for the first read? Every
> successful reuse passes through xmin_installed, so the second read is the final
> validation.
Good point.
Patch 0003 has been adjusted to only issue the membarrier read after
installing a new xmin. The xmin-installed path now doesn't issue any
membarriers.
Attached is v3, which is a rebase onto head with the two issues that
Bertrand raised addressed.
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)
| Attachment | Content-Type | Size |
|---|---|---|
| v3-0001-Split-out-TransamVariablesData-from-transam.h.patch | application/octet-stream | 12.5 KB |
| v3-0002-procarray-Implement-optimistic-lockless-snapshot-.patch | application/octet-stream | 7.2 KB |
| v3-0003-procarray-Implement-full-lockless-snapshot-reuse.patch | application/octet-stream | 9.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dean Rasheed | 2026-12-03 20:21:44 | Re: Back-patch v19 improvements to common/int128.h? |
| Previous Message | David Rowley | 2026-12-03 20:07:10 | Re: Should we add timing output to pg_upgrade? |