Re: Performance improvements for src/port/snprintf.c

Andrew Gierth <andrew@tao11.riddles.org.uk>

From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Andres Freund <andres@anarazel.de>
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-06T03:10:00Z
Lists: pgsql-hackers
>>>>> "Andres" == Andres Freund <andres@anarazel.de> writes:

 Andres> I'm not convinced. Because of some hypothetical platform that
 Andres> may introduce strfromd() in a broken/slower manner, but where
 Andres> sprintf() is correct, we should not do the minimal work to
 Andres> alleviate an actual performance bottleneck in a trivial manner
 Andres> on linux? Our most widely used platform? If we find a platform
 Andres> where it's borked, we could just add a small hack into their
 Andres> platform template file.

So here's a thing: I finally got to doing my performance tests for using
the Ryu float output code in float[48]out.

Ryu is so blazing fast that with it, COPY of a table with 2million rows
of 12 random float8 columns (plus id) becomes FASTER in text mode than
in binary mode (rather than ~5x slower):

copy binary flttst to '/dev/null';  -- binary
Time: 3222.444 ms (00:03.222)

copy flttst to '/dev/null';  -- non-Ryu
Time: 16416.161 ms (00:16.416)

copy flttst to '/dev/null';  -- Ryu
Time: 2691.642 ms (00:02.692)

(And yes, I've double-checked the results and they look correct, other
than the formatting differences. COPY BINARY seems to have a bit more
overhead than text mode, even for just doing integers, I don't know
why.)

-- 
Andrew (irc:RhodiumToad)


Commits

  1. Improve snprintf.c's handling of NaN, Infinity, and minus zero.

  2. Rationalize snprintf.c's handling of "ll" formats.

  3. Provide fast path in snprintf.c for conversion specs that are just "%s".

  4. Make assorted performance improvements in snprintf.c.

  5. Set snprintf.c's maximum number of NL arguments to be 31.

  6. Always use our own versions of *printf().