From owner-freebsd-hackers@freebsd.org Mon Jul 2 15:44:14 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E48CD102D61B for ; Mon, 2 Jul 2018 15:44:13 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4AA2F8E3E2 for ; Mon, 2 Jul 2018 15:44:13 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w62Fi1Ic024233 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 2 Jul 2018 18:44:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w62Fi1Ic024233 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w62Fi1n5024232; Mon, 2 Jul 2018 18:44:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 2 Jul 2018 18:44:01 +0300 From: Konstantin Belousov To: Thomas Munro Cc: freebsd-hackers@freebsd.org Subject: Re: Patching setproctitle() to go faster, for PostgreSQL Message-ID: <20180702154401.GB2430@kib.kiev.ua> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Jul 2018 15:44:14 -0000 On Tue, Jul 03, 2018 at 12:53:28AM +1200, Thomas Munro wrote: > 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).