Re: Performance improvements for src/port/snprintf.c
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers@lists.postgresql.org, Thomas Munro <thomas.munro@enterprisedb.com>, Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru>
Date: 2018-10-12T04:36:24Z
Lists: pgsql-hackers
Hi, On 2018-10-07 12:59:18 +0100, Andrew Gierth wrote: > >>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes: > > Tom> Now, "shortest value that converts back exactly" is technically > Tom> cool, but I am not sure that it solves any real-world problem that > Tom> we have. > > Well, it seems to me that it is perfect for pg_dump. > > Also it's kind of a problem that our default float output is not > round-trip safe - people do keep wondering why they can select a row and > it'll show a certain value, but then doing WHERE col = 'xxx' on that > value does not find the row. Yes, testing equality of floats is bad, but > there's no reason to put in extra landmines. +1 > Tom> I'm also worried that introducing it would result in complaints like > Tom> https://www.postgresql.org/message-id/CANaXbVjw3Y8VmapWuZahtcRhpE61hsSUcjquip3HuXeuN8y4sg%40mail.gmail.com > > Frankly for a >20x performance improvement in float8out I don't think > that's an especially big deal. +1. There's plenty complaints where we just say "sorry that it bothers you, but these larger concerns made us that way". > I do not see any obvious way to use this code to generate the same > output in the final digits that we currently do (in the sense of > overly-exact values like outputting 1.89999999999999991 for 1.9 when > extra_float_digits=3). But, why would that be required? Just to placate people wanting exactly the same output as before? I don't quite get how that'd be a useful requirement. Obviously we *do* need to support outputting non-exponent style output where appropriate, but that should mostly be different massaging of d2d()'s output, instead of calling to_chars() as the ryu upstream code does. ISTM we also need to support *reducing* the precision (for the case where people intentionally reduce extra_float_digits), but that similarly should be a SMOP, right?- - Andres
Commits
-
Improve snprintf.c's handling of NaN, Infinity, and minus zero.
- 6eb3eb577d76 12.0 landed
-
Rationalize snprintf.c's handling of "ll" formats.
- 595a0eab7f42 12.0 landed
-
Provide fast path in snprintf.c for conversion specs that are just "%s".
- 6d842be6c118 12.0 landed
-
Make assorted performance improvements in snprintf.c.
- abd9ca377d66 12.0 landed
-
Set snprintf.c's maximum number of NL arguments to be 31.
- 625b38ea0e98 12.0 cited
-
Always use our own versions of *printf().
- 96bf88d52711 12.0 cited