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

From: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
To: Arjan van de Ven <arjan(at)linux(dot)intel(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: src/port/snprintf.c: Optimize the common base=10 case in fmtint
Date: 2021-10-26 16:45:32
Message-ID: 92FF353A-B28A-4479-BFFE-35485CD6C94A@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Oct 26, 2021, at 7:57 AM, Arjan van de Ven <arjan(at)linux(dot)intel(dot)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 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".


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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-10-26 16:56:44 Re: src/port/snprintf.c: Optimize the common base=10 case in fmtint
Previous Message Alvaro Herrera 2021-10-26 16:36:03 Re: Refactoring: join MakeSingleTupleTableSlot() and MakeTupleTableSlot()