Re: [PATCH] Use 128-bit math to accelerate numeric division, when 8 < divisor digits <= 16

From: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
To: Joel Jacobson <joel(at)compiler(dot)org>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Use 128-bit math to accelerate numeric division, when 8 < divisor digits <= 16
Date: 2023-01-23 05:06:40
Message-ID: CAFBsxsHgygbSn0fc=LQgsQyjaR=EkGFJMJ4-sR-Styjgjbc3RA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jan 22, 2023 at 10:42 PM Joel Jacobson <joel(at)compiler(dot)org> wrote:

> I did write the code like you suggest first, but changed it,
> since I realised the extra "else if" needed could be eliminated,
> and thought div_var_int64() wouldn't be slower than div_var_int() since
> I thought 64-bit instructions in general are as fast as 32-bit
instructions,
> on 64-bit platforms.

According to Agner's instruction tables [1], integer division on Skylake
(for example) has a latency of 26 cycles for 32-bit operands, and 42-95
cycles for 64-bit.

[1] https://www.agner.org/optimize/instruction_tables.pdf

--
John Naylor
EDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-01-23 05:15:15 Re: Add a new pg_walinspect function to extract FPIs from WAL records
Previous Message Hayato Kuroda (Fujitsu) 2023-01-23 04:57:24 RE: [Proposal] Add foreign-server health checks infrastructure