Re: [PATCH v2] src/port/snprintf.c: Optimize the common base=10 case in fmtint

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Chapman Flack <chap@anastigmatix.net>, Arjan van de Ven <arjan@linux.intel.com>, Japin Li <japinli@hotmail.com>, pgsql-hackers@postgresql.org, mark.dilger@enterprisedb.com, pgsql-hackers@lists.postgresql.org
Date: 2021-10-28T20:27:49Z
Lists: pgsql-hackers
Hi,

On 2021-10-28 13:46:49 -0400, Tom Lane wrote:
> Personally, I failed to measure any speedup at all on pgbench, either
> in the init phase or regular transactions; whatever difference there
> may be is below the noise level.  However, I wrote a simple C function
> with a tight loop around snprintf(), and that showed about a 2X
> improvement, so there is some win here.

Odd - at least with an earlier patch I saw optimized pgbench initialization go
down by ~25%.


> I went ahead and pushed it with a rewritten comment.

Imo the code now is a bit odd, because we first switch (type) setting base,
and then separately have branches for the different bases.

Greetings,

Andres Freund



Commits

  1. Speed up printing of integers in snprintf.c.