Re: Performance improvements for src/port/snprintf.c
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Andres Freund <andres@anarazel.de>, pgsql-hackers@lists.postgresql.org,
Thomas Munro <thomas.munro@enterprisedb.com>,
Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru>
Date: 2018-10-07T19:40:51Z
Lists: pgsql-hackers
Andrew Gierth <andrew@tao11.riddles.org.uk> writes: > "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. Perhaps. I was hoping for something we could slot into snprintf.c; not being able to select the number of digits to output is clearly a deal-breaker for that usage. But perhaps it's reasonable to allow "extra_float_digits = 3" to be redefined as meaning "use the shortest value that converts back exactly" in float[48]out. However, it seems like it should still be on the table to look at other code that just does sprintf's job faster (such as the stb code Alexander mentioned). If anything like that is acceptable for the general case, then we have to ask whether ryu is enough faster than *that* code, not faster than what we have now, to justify carrying another umpteen KB of independent code path for the dump-and-restore case. > 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. Unfortunately, I do not think it's going to be acceptable for default float output (as opposed to the dump/restore case) to become round-trip safe. The number of people complaining today would be dwarfed by the number of people complaining about extra garbage digits in their results. There isn't any compromise that will make things "just work" for people who are unaware of the subtleties of float arithmetic. regards, tom lane
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