Discussion:
Patching setproctitle() to go faster, for PostgreSQL
Thomas Munro
2018-07-02 12:53:28 UTC
Permalink
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
Konstantin Belousov
2018-07-02 15:44:01 UTC
Permalink
Post by Thomas Munro
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.
The kernel chunk looks fine.

For the libc, I am not so sure. Why five, why not taking into the
account the frequency, what users could do if they want the old
behaviour e.g. to see the args in vmcore, and so on.

Is modifying posgresql sources acceptable ? If yes, I propose that you add
setproctitle_fast(3) (I do not insist on the name).
Thomas Munro
2018-07-03 13:00:44 UTC
Permalink
Post by Konstantin Belousov
The kernel chunk looks fine.
For the libc, I am not so sure. Why five, why not taking into the
account the frequency, what users could do if they want the old
behaviour e.g. to see the args in vmcore, and so on.
Ok.
Post by Konstantin Belousov
Is modifying posgresql sources acceptable ? If yes, I propose that you add
setproctitle_fast(3) (I do not insist on the name).
Ok, here's a first attempt at that:

https://reviews.freebsd.org/D16111

Thanks for the feedback!

Loading...