Re: src/port/snprintf.c: Optimize the common base=10 case in fmtint - Mailing list pgsql-hackers

From Mark Dilger
Subject Re: src/port/snprintf.c: Optimize the common base=10 case in fmtint
Date
Msg-id 92FF353A-B28A-4479-BFFE-35485CD6C94A@enterprisedb.com
Whole thread Raw
In response to src/port/snprintf.c: Optimize the common base=10 case in fmtint  (Arjan van de Ven <arjan@linux.intel.com>)
Responses Re: src/port/snprintf.c: Optimize the common base=10 case in fmtint
List pgsql-hackers

> On Oct 26, 2021, at 7:57 AM, Arjan van de Ven <arjan@linux.intel.com> wrote:
>
> By special casing the super common case of base==10, the (gcc) compiler can (and will)
> replace the divide by a multiply with 0xcccccccccccccccd, yielding a lot faster code.
> (fmtint dropped drastically in the perf profiles after this change)

It appears fmtint only has three options for base, being 10, 16, and 8.  Have you profiled with either of the others
specialcased as well?  I don't see much use in optimizing for octal, but hexadecimal is used quite a bit in wal with
patternslike "%08X%08X%08X". 

—
Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company






pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Refactoring: join MakeSingleTupleTableSlot() and MakeTupleTableSlot()
Next
From: Andres Freund
Date:
Subject: Re: src/port/snprintf.c: Optimize the common base=10 case in fmtint