Re: tweaking perfect hash multipliers

From: John Naylor <john(dot)naylor(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tweaking perfect hash multipliers
Date: 2020-03-30 19:10:59
Message-ID: CACPNZCuSmUXh-xjOUtKQYtJRiPf45_KhVcM6P_ExDv+VW0T_UA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 31, 2020 at 2:31 AM Andres Freund <andres(at)anarazel(dot)de> wrote:
>
> Hi,
>
> On 2020-03-30 21:33:14 +0800, John Naylor wrote:
> > Then I used the attached program to measure various combinations of
> > compiled instructions using two constant multipliers iterating over
> > bytes similar to a generated hash function.
>
> It looks like you didn't attach the program?

Funny, I did, but then decided to rename the files. Here they are. I
tried to make the loop similar to how it'd be in the actual hash
function, but leaving out the post-loop modulus and array access. Each
loop iteration is dependent on the last one's result.

> It's a bit complicated by the fact that there's more execution ports to
> execute shift/add than there ports to compute some form of leas. And
> some of that won't easily be measurable in a micro-benchmark, because
> there'll be dependencies between the instruction preventing any
> instruction level parallelism.
>
> I think the form of lea generated here is among the ones that can only
> be executed on port 1. Whereas e.g. an register+register/immediate add
> can be executed on four different ports.

That's interesting, I'll have to look into that.

Thanks for the info!

--
John Naylor https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
test-const-mult.c application/octet-stream 7.5 KB
test-const-mult-2.c application/octet-stream 1.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2020-03-30 19:16:31 Re: backup manifests
Previous Message Andres Freund 2020-03-30 19:05:05 Re: [PATCH] remove condition always true (/src/backend/access/heap/vacuumlazy.c)