| From: | Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com> |
|---|---|
| To: | Andy Fan <zhihuifan1213(at)163(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: ProcArrayAdd/ProcArrayRemove in Prepared Transaction |
| Date: | 2026-08-21 10:58:36 |
| Message-ID: | CAEze2Wicp2_jzWZm4h-A5P4hV1U_aRw6F=f81DLvanN1_eA_OA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, 21 Aug 2026 at 09:29, Andy Fan <zhihuifan1213(at)163(dot)com> wrote:
>
> Hi,
>
> Currently when we create a PreparedTransaction, we call ProcArrayAdd.
> Then when we FinishPreparedTransaction, we canl ProcArrayRemove. Both
> functions need do lots of memmove when holding a LW_EXCLUSIVE lock on
> ProcArrayLock. I guess this would be a common bottleneck on a
> PostgreSQL-based distributed database.
>
>
> Should we do something to improve this? The direct idea in my mind is we
> can cache N PGPROCs for prepared xact in ProcArray, it should be the
> number of concurrently *active* preapred transaction which maybe much
> less than max_prepared_xacts value, so it probably not too bad for
> ProcArray Scan. Then we can remove the both ProcArrayAdd and
> ProcArrayRemove. However besides we have to manage the PGPROC state
> carefully for these cached PGPROCs, another troubles is the PGPROC is
> bind to database and user, this make them hard to manage, any idea how
> to handle this?
>
> I want to PoC the above idea, but I hope some difference voice or the
> suggestion about the database/user stuff.
There's another thread on improving the performance of
ProcArrayAdd/Remove (primarily in non-huge-pages systems), which might
be of interest to you: [0].
As for a "hot" section for PGPROCS, one doesn't follow the current
dense array ordering rules: I think that could be interesting, but it
would trade GetSnapshotData's predictable linear memory accesses for
PROC registration efficiency. Benchmarks and measurements should show
whether that's a worthwhile trade-off; I think for it to be worthwhile
this unordered-by-procnumber section should probably remain very
small.
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jakub Wartak | 2026-08-21 11:00:57 | Re: pg_upgrade --copy-file-range fails with EINVAL on Linux 4.19 |
| Previous Message | Andrey Borodin | 2026-08-21 10:31:30 | Re: toast table corrupted by vacuum - missing chunk number 0 for toast value |