pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@lists.postgresql.org, Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru>
Subject: Re: Performance improvements for src/port/snprintf.c
Date: Mon, 08 Oct 2018 05:36:20 +0100
Message-ID: <874ldx9iz3.fsf@news-spur.riddles.org.uk> (raw )
In-Reply-To: <14721.1538941251@sss.pgh.pa.us >
References: <28321.1538585692@sss.pgh.pa.us >
<20181003170043.thdyezozi343dkuc@alap3.anarazel.de >
<2132.1538587869@sss.pgh.pa.us >
<20181003173639.tncawup2nnkp7vbv@alap3.anarazel.de >
<2435.1538588403@sss.pgh.pa.us >
<20181003174513.wxjxfj7eepytnlqa@alap3.anarazel.de >
<3316.1538589695@sss.pgh.pa.us >
<20181003183552.xaams6fau3i7oybj@alap3.anarazel.de >
<6797.1538592539@sss.pgh.pa.us >
<30726.1538754899@sss.pgh.pa.us >
<20181005165819.h7gdzcbwhnhofq2b@alap3.anarazel.de >
<87sh1jaiyq.fsf@news-spur.riddles.org.uk >
<13967.1538795773@sss.pgh.pa.us >
<87o9c7ahjh.fsf@news-spur.riddles.org.uk >
<15405.1538798355@sss.pgh.pa.us >
<87k1mvafjr.fsf@news-spur.riddles.org.uk >
<19798.1538837565@sss.pgh.pa.us >
<878t3a9w7r.fsf@news-spur.riddles.org.uk >
<14721.1538941251@sss.pgh.pa.us >
>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
Tom> However, it seems like it should still be on the table to look at
Tom> other code that just does sprintf's job faster (such as the stb
Tom> code Alexander mentioned).
The stb sprintf is indeed a lot faster for floats than other sprintfs,
but (a) it's still quite a lot slower than Ryu (COPY of my test table is
4.2 seconds with stb, vs 2.7 seconds with Ryu), and (b) it also produces
changes in the insignificant digits, so while (it claims) the values are
still round-trip convertible, they are neither the shortest
representation nor the exact representation.
For example, consider 1.9, which is 0x3FFE666666666666:
exact value: 1.899999999999999911182158029987476766109466552734375
accepted input range:
min: 1.89999999999999980015985556747182272374629974365234375
max: 1.90000000000000002220446049250313080847263336181640625
exact value rounded to 18 SF: 1.89999999999999991
Ryu output: 1.9E0
STB (%*.18g) output: 1.89999999999999992
sprintf (%*.18g) output: 1.89999999999999991
So while STB's output is in the acceptable range, it's not the result of
rounding the exact value to 18 digits (as sprintf does on my system at
least) and nor is it the shortest. Testing a bunch of random values it
usually seems to be off from the rounded exact result by +/- 1 in the
last digit.
--
Andrew (irc:RhodiumToad)
view thread (65+ messages) latest in thread
Message-ID: <874ldx9iz3.fsf@news-spur.riddles.org.uk>
Permalink: ../874ldx9iz3.fsf@news-spur.riddles.org.uk/
Also on: postgresql.org/message-id/874ldx9iz3.fsf@news-spur.riddles.org.uk
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: andrew@tao11.riddles.org.uk, tgl@sss.pgh.pa.us, andres@anarazel.de, thomas.munro@enterprisedb.com, a.kuzmenkov@postgrespro.ru
Subject: Re: Performance improvements for src/port/snprintf.c
In-Reply-To: <874ldx9iz3.fsf@news-spur.riddles.org.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox