| From: | Roman Khapov <rkhapov(at)yandex-team(dot)ru> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | kqueue backend for pgbench |
| Date: | 2026-10-26 06:41:28 |
| Message-ID: | 5EF180BD-3951-4E8C-903D-D91EF54A338D@yandex-team.ru |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi hackers!
While working on [1] I run performance tests on different environments,
including laptop with macOS. pgbench is usually chosen for this,
but on one of the last runs I discovered that it uses select() on macOS (which lacks
the ppoll() syscall), which caps the max amount of clients at 1024 (FD_SETSIZE).
This can be fixed with new implementation of socket_set based on kqueue().
The only wrinkle is fact that select() and ppoll() is stateless, while kqueue() is not
(registration persists in kernel across kevent() calls), so wait_on_socket_set() must be
written in harder way than other implementations:
- disable stale registrations: EV_DISABLE for every fd to drain error for closed fds
- enable current set with EV_ENABLE, call kevent()
- report results (save flags in socket_set->input_ready) + preserving the set for the next iteration
POC-patch attached, any feedback would be appreciated!
[1] - https://github.com/yandex/odyssey
--
Best regards,
Roman Khapov
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-pgbench-add-kqueue-implementation-of-the-socket-set-.patch | application/octet-stream | 8.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Roman Khapov | 2026-10-26 06:41:34 | Print pgbench results on SIGINT |
| Previous Message | Nisha Moond | 2026-10-26 06:29:19 | Re: Proposal: Conflict log history table for Logical Replication |