Patching setproctitle() to go faster, for PostgreSQL

Thomas Munro munro at ip9.org
Mon Jul 2 12:53:32 UTC 2018


Hi FreeBSD hackers,

PostgreSQL's update_process_titles setting, which defaults to on,
slows busy databases down quite noticeably on FreeBSD and so a lot of
people turn it off.  Having that information in ps/top/htop is nice,
so I don't like turning it off.  It was a rainy Sunday here yesterday
so I decided to hack on that.  I wrote an experimental patch,
attached, that essentially reverts to the ancient syscall-free BSD
behaviour (?) on a per-process basis, for processes that are
update-heavy.  That raises some interesting questions about torn
reads, I admit...

I didn't see much difference in "pgbench" on my laptop, but on an AWS
m4.10xlarge (40 vCPU) machine I could easily see a difference.  I
think there is probably a contention effect somewhere that gets worse
with more concurrency.

pgbench -i -s 10 postgres
pgbench -T60 -c 40 -j 40 -S -M prepared postgres

Stock 11.2,   update_process_titles = on:     472873 TPS (default)
Stock 11.2,   update_process_titles = off:    539391 TPS (~13% faster
than default)
Patched 11.2, update_process_titles = on:     519733 TPS (~10% faster
than default)

I'd be grateful for any feedback.

Thanks,

Thomas Munro
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Speed-up-setproctitle-for-frequent-callers.patch
Type: application/octet-stream
Size: 3780 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20180703/0e9b2be8/attachment.obj>


More information about the freebsd-hackers mailing list