Hi,

Here are some patches to get rid of frequent system calls.

0001 changes all qualifying WaitLatch() calls to use a new function
WaitMyLatch() that reuses a common WaitEventSet.  That's for callers
that only want to wait for their own latch or an optional timeout,
with automatic exit-on-postmaster-death.

0002 changes condition_variable.c to use WaitMyLatch(), instead of its
own local thing like that.  Perhaps this makes up for the use of the
extra fd consumed by 0001.

0003 changes pgstat.c to use its own local reusable WaitEventSet.

To see what I'm talking about, try tracing a whole cluster with eg
strace/truss/dtruss -f postgres -D pgdata.  This applies to Linux
systems, or BSD/macOS systems with the nearby kqueue patch applied.
On systems that fall back to poll(), there aren't any setup/teardown
syscalls.

Attachment: 0001-Add-WaitMyLatch-to-replace-many-WaitLatch-calls.patch
Description: Binary data

Attachment: 0002-Use-WaitMyLatch-for-condition-variables.patch
Description: Binary data

Attachment: 0003-Introduce-a-reusable-WaitEventSet-for-the-stats-coll.patch
Description: Binary data

Reply via email to