Re: Performance improvements for src/port/snprintf.c
Thomas Munro <thomas.munro@enterprisedb.com>
From: Thomas Munro <thomas.munro@enterprisedb.com>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Andres Freund <andres@anarazel.de>, Tom Lane <tgl@sss.pgh.pa.us>, Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-09-27T04:04:08Z
Lists: pgsql-hackers
On Thu, Sep 27, 2018 at 3:55 PM Andrew Gierth <andrew@tao11.riddles.org.uk> wrote: > >>>>> "Andres" == Andres Freund <andres@anarazel.de> writes: > Andres> Hm, stb's results just for floating point isn't bad. The above > Andres> numbers were for %f %f. But as the minimal usage would be about > Andres> the internal usage of dopr(), here's comparing %.*f: > > Andres> snprintf time = 1324.87 ms total, 0.000264975 ms per iteration > Andres> pg time = 1434.57 ms total, 0.000286915 ms per iteration > Andres> stbsp time = 552.14 ms total, 0.000110428 ms per iteration > > Hmm. We had a case recently on IRC where the performance of float8out > turned out to be the major bottleneck: a table of about 2.7 million rows > and ~70 float columns showed an overhead of ~66 seconds for doing COPY > as opposed to COPY BINARY (the actual problem report was that doing > "select * from table" from R was taking a minute+ longer than expected, > we got comparative timings for COPY just to narrow down causes). > > That translates to approx. 0.00035 ms overhead (i.e. time(float8out) - > time(float8send)) per conversion (Linux server, hardware unknown). > > That 66 seconds was the difference between 18s and 1m24s, so it wasn't a > small factor but totally dominated the query time. For perfect and cheap round trip to ASCII, not for human consumption, I wonder about the hexadecimal binary float literal format from C99 (and showing up in other places too). -- Thomas Munro http://www.enterprisedb.com
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