Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5KM9-0005hF-CH for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Sep 2018 00:40:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g5KM7-0003mu-5s for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Sep 2018 00:40:35 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5KM5-0003ml-TA for pgsql-hackers@lists.postgresql.org; Thu, 27 Sep 2018 00:40:34 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5KLx-0007ne-MU for pgsql-hackers@lists.postgresql.org; Thu, 27 Sep 2018 00:40:32 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 8CEF521CE2; Wed, 26 Sep 2018 20:40:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 26 Sep 2018 20:40:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=wJX54XQAEe7WrQAJUOXWJ+3qD5gB765iqFhinGkReE8=; b=IcUppgrK R8nWIgf86MM5CSH3zbSlhEZHBk6mt9a2/s07jhY5mqsjf1JBG6w8nlStyzoFOQK7 AUzfNLHi/qL77pafuchm4ySqAKkzHSxKdl+uHjoRvTr0tOlj7LSzsjWbOx/dkN/B 3RpY04sYERKaOt3tovcCKbue0gOi/CE5IfI170VgeYZ0BT68wTFMX5EaguxFruQK JNvgTyfRhgysOsybUv02vjcMw0BsyS1aY0v/tYXH/XcLp0PXbS9Kwf9glWo6iIre /1dE7gg55PfxvqXy4tg4Ni+6qPbGFS/t/yj8Ov2X22aTHQmaPxBI08I6PeIYZoCf EYdcCf0gdLrPwg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=wJX54XQAEe7WrQAJUOXWJ+3qD5gB7 65iqFhinGkReE8=; b=L0iBxQDFtbz122Z7rq+cdGhps1EjJDYAufMzCsuJfIBqE yVqYopYHEYpQWgIE076+XcO2eHve03fS+DQxnh6yASl4PPoMrzd8YttDqV7qnAZz y4LHi7mJuPPDwB0/XX1l/R/SPg9nFvM5RaPT/FATjCLI6T4yr+E2FXePq8jLqd5O XcG+Cm0+rva1YXI7cn+Hxr+cb8+p+LJN5T0A6pGrzy9CNoEYmexQdO+YJoEBE7yu 6NMWD692VJ1BHsnAxcJJtpESYu/CA0XiQ3zMOPU3vJfmbZAxBwzyExqtRLpvkEm6 D+PsPC1032W8MAUTRDOtWhzrHfjjEjTjf0zy9/oAg== X-ME-Proxy: X-ME-Sender: Received: from intern.anarazel.de (c-98-210-140-171.hsd1.ca.comcast.net [98.210.140.171]) by mail.messagingengine.com (Postfix) with ESMTPA id 84AC0102E2; Wed, 26 Sep 2018 20:40:23 -0400 (EDT) Date: Wed, 26 Sep 2018 17:40:22 -0700 From: Andres Freund To: Tom Lane Cc: Alexander Kuzmenkov , pgsql-hackers@lists.postgresql.org Subject: Re: Performance improvements for src/port/snprintf.c Message-ID: <20180927004022.lfhffbj3roxzf5ca@alap3.anarazel.de> References: <11787.1534530779@sss.pgh.pa.us> <2238.1534716465@sss.pgh.pa.us> <15785.1536776055@sss.pgh.pa.us> <20180926220419.lorxpb564gakdjkz@alap3.anarazel.de> <20180926221814.el5nwmkez6zfmzbz@alap3.anarazel.de> <14302.1538005507@sss.pgh.pa.us> <20180926235821.zmpxqv66ob7v2ffi@alap3.anarazel.de> <15882.1538007944@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <15882.1538007944@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-09-26 20:25:44 -0400, Tom Lane wrote: > Andres Freund writes: > > On 2018-09-26 19:45:07 -0400, Tom Lane wrote: > >> No, there are no additional layers that weren't there before --- > >> snprintf.c's snprintf() slots in directly where the platform's did before. > > > Hm? What I mean is that we can't realistically be faster with the > > current architecture, because for floating point we end up doing glibc > > sprintf() in either case. > > Oh, you mean specifically for the float conversion case. I still say > that I will *not* accept judging this code solely on the float case. Oh, it should definitely not be judged solely based on floating point, we agree. > The string and integer cases are at least as important if not more so. I think the integer stuff has become a *little* bit less important, because we converted the hot cases over to pg_lto etc. > >> Interesting. strfromd() is a glibc-ism, and a fairly recent one at > >> that (my RHEL6 box doesn't seem to have it). > > > It's C99 afaict. > > It's not in POSIX 2008, and I don't see it in my admittedly-draft > copy of C99 either. But that's not real relevant -- I don't see > much reason not to use it if we want a quick and dirty answer for > the platforms that have it. Right, I really just wanted some more baseline numbers. > If we had more ambition, we might consider stealing the float > conversion logic out of the "stb" library that Alexander pointed > to upthread. It says it's public domain, so there's no license > impediment to borrowing some code ... Yea, I started to play around with doing so with musl, but based on early my benchmarks it's not fast enough to bother. I've not integrated it into our code, but instead printed two floating point numbers with your test: musl 5000000 iterations: snprintf time = 3144.46 ms total, 0.000628892 ms per iteration pg_snprintf time = 4215.1 ms total, 0.00084302 ms per iteration ratio = 1.340 glibc 5000000 iterations: snprintf time = 1680.82 ms total, 0.000336165 ms per iteration pg_snprintf time = 2629.46 ms total, 0.000525892 ms per iteration ratio = 1.564 So there's pretty clearly no point in even considering starting from musl. Greetings, Andres Freund