In https://reviews.freebsd.org/D16111 we got setproctitle_fast(), a way to speed up PostgreSQL's frequent process title updates on FreeBSD. I can get the PostgreSQL side of that committed to PostgreSQL 12, but it's not PostgreSQL project policy to backpatch new features to older releases (only bug fixes). How about carrying patches for the stable PostgreSQL releases in FreeBSD ports? Then 12-CURRENT users can benefit from the speed-up and provide feedback now. This covers PostgreSQL 9.5, 9.6 and 10. We can take care of PostgreSQL 11 when it's released, quite soon.
Looks good. We should probably also change the default configuration if setproctitle_fast exists. When was it introduced, in which OSVERSION?
files/patch-src_backend_utils_misc_postgresql.conf.sample turns setproctitle off.
I'm not sure... isn't the important question whether the postgres binary was built with this option? If you're using a pkg compiled for 11.0 and you're running on 11.3, then your postgres binary doesn't use setproctitle_fast(), even though the OS has it. Would it make sense to check if "nm /path/to/postgres | grep setproctitle_fast"?
BTW I just pushed this change to PostgreSQL master (PostgreSQL 12-to-be).