Re: Add per-backend lock statistics

From: Rui Zhao <zhaorui126(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Tatsuya Kawata <kawatatatsuya0913(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add per-backend lock statistics
Date: 2026-06-25 15:40:19
Message-ID: CAHWVJhGRdTmruVLpfGuOBDF9-QHE6mk5OAMoSvpw6aPx223A7w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Bertrand,

I reviewed and tested v2; it builds cleanly. The implementation closely
mirrors the existing per-backend IO/WAL stats (same flush path, struct
layout, and backend-type guard), and the hot path is untouched: the
per-backend counters piggyback on the existing global counting points
(pgstat_count_lock_waits / pgstat_count_lock_fastpath_exceeded), so they
only fire where pg_stat_lock already counts -- fastpath_exceeded when the
fast-path slot limit is exceeded, and waits/wait_time only after a wait
longer than deadlock_timeout.

One tiny nit: in pgstat_count_backend_lock_waits() and
pgstat_count_backend_lock_fastpath_exceeded(), the Assert() is directly
followed by the counter update. A blank line after the Assert() would read
a bit better and is the more usual style in this code.

Otherwise LGTM.

Regards,
Rui

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Baji Shaik 2026-06-25 15:44:54 Re: [PATCH] COPY TO FORMAT json: respect column list order
Previous Message Bertrand Drouvot 2026-06-25 15:05:01 Re: In core use of RegisterXactCallback() and RegisterSubXactCallback()