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 1g5LMM-0008MT-UV for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Sep 2018 01:44:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g5LML-0001YK-5B for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Sep 2018 01:44:53 +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 1g5LMK-0001Y5-QP for pgsql-hackers@lists.postgresql.org; Thu, 27 Sep 2018 01:44:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5LMD-0000hY-Qc for pgsql-hackers@lists.postgresql.org; Thu, 27 Sep 2018 01:44:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w8R1ifXv017059; Wed, 26 Sep 2018 21:44:41 -0400 From: Tom Lane To: Andres Freund cc: Alexander Kuzmenkov , pgsql-hackers@lists.postgresql.org Subject: Re: Performance improvements for src/port/snprintf.c In-reply-to: <20180927011814.kpncoksuqq3gy44s@alap3.anarazel.de> References: <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> <20180927004022.lfhffbj3roxzf5ca@alap3.anarazel.de> <20180927005705.shbl3n5hq3t65n2j@alap3.anarazel.de> <20180927011814.kpncoksuqq3gy44s@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Wed, 26 Sep 2018 18:18:14 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17057.1538012681.1@sss.pgh.pa.us> Date: Wed, 26 Sep 2018 21:44:41 -0400 Message-ID: <17058.1538012681@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > Reading around the interwebz lead me to look at ryu > https://dl.acm.org/citation.cfm?id=3192369 > https://github.com/ulfjack/ryu/tree/46f4c5572121a6f1428749fe3e24132c3626c946 > That's an algorithm that always generates the minimally sized > roundtrip-safe string output for a floating point number. That makes it > insuitable for the innards of printf, but it very well could be > interesting for e.g. float8out, especially when we currently specify a > "too high" precision to guarantee round-trip safeity. Yeah, the whole business of round-trip safety is a bit worrisome. If we change printf, and it produces different low-order digits than before, will floats still round-trip correctly? I think we have to ensure that they do. If we just use strfromd(), then it's libc's problem if the results change ... but if we stick in some code we got from elsewhere, it's our problem. BTW, were you thinking of plugging in strfromd() inside snprintf.c, or just invoking it directly from float[48]out? The latter would presumably be cheaper, and it'd solve the most pressing performance problem, if not every problem. regards, tom lane