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

2021-10-27 Thread Arjan van de Ven
On 10/26/2021 6:39 PM, Tom Lane wrote: Japin Li writes: Why do we need likely() for base=10, however, base=16 and base=8 don't need? Yeah, I was a little unconvinced about that too. I concur with writing it as an if/else chain instead of a switch, but I'm not sure that likely() adds anything

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

2021-10-26 Thread Arjan van de Ven
[PATCH v2] src/port/snprintf.c: Optimize the common base=10 case in fmtint fmtint() turns an integer into a string for a given base, and to do this it does a divide/modulo operation iteratively. The only possible base values are 8, 10 and 16 On just about any CPU, divides are a pretty expensive

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

2021-10-26 Thread Arjan van de Ven
On 10/26/2021 10:51 AM, Tom Lane wrote: Mark Dilger writes: It appears fmtint only has three options for base, being 10, 16, and 8. Have you profiled with either of the others special cased as well? I don't see much use in optimizing for octal, but hexadecimal is used quite a bit in wal wit

src/port/snprintf.c: Optimize the common base=10 case in fmtint

2021-10-26 Thread Arjan van de Ven
src/port/snprintf.c: Optimize the common base=10 case in fmtint fmtint() turns an integer into a string for a given base, and to do this it does a divide/modulo operation iteratively. On just about any CPU, divides are a pretty expensive operation, generally 10x to 20x or more expensive than add