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

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, Arjan van de Ven <arjan(at)linux(dot)intel(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: src/port/snprintf.c: Optimize the common base=10 case in fmtint
Date: 2021-10-26 18:15:35
Message-ID: 20211026181535.6cncdjfpr4u3frr4@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2021-10-26 13:51:55 -0400, Tom Lane wrote:
> Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com> 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 with patterns like "%08X%08X%08X".
>
> I'd be inclined to just hard-wire the three allowed cases, and not have
> an arbitrary-divisor code path at all.

Yea, I came to the same conclusion. But I'd implement it by moving the
division into a separate inline function called from the switch. I tested that
locally and it works, but I got sidetracked by [1].

Greetings,

Andres Freund

[1] https://postgr.es/m/20211026180454.xcjmu3kwmn3tka57%40alap3.anarazel.de

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-10-26 18:31:40 Re: changes in pgport etc doesn't cause client programs to be relinked
Previous Message Arjan van de Ven 2021-10-26 18:13:14 Re: src/port/snprintf.c: Optimize the common base=10 case in fmtint