pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: John Naylor <john.naylor@enterprisedb.com>
Cc: John Naylor <jcnaylor@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: optimize lookups in snapshot [sub]xip arrays
Date: Sat, 6 Aug 2022 11:13:26 -0700
Message-ID: <20220806181326.GA1216305@nathanxps13> (raw)
In-Reply-To: <20220805220434.6h2aa7eww5rxird6@awork3.anarazel.de>
References: <20220802221301.GA742739@nathanxps13>
	<20220802225539.nm7bgkwvkpzgib5x@awork3.anarazel.de>
	<20220802234357.GA802740@nathanxps13>
	<20220803180658.3ofq6v34wxchg4wc@awork3.anarazel.de>
	<20220803202540.GA1088968@nathanxps13>
	<CAFBsxsH51bBtyr3rf13x7YMNkFfuzZPSQxxbfUepBj8m4=ck=Q@mail.gmail.com>
	<20220804221551.GA1090071@nathanxps13>
	<CAFBsxsGmNefB-LAo8hNXLDAwWN0vHXc6H2A+NfFUQrj=rn50DQ@mail.gmail.com>
	<20220805202510.GA1208450@nathanxps13>
	<20220805220434.6h2aa7eww5rxird6@awork3.anarazel.de>

On Fri, Aug 05, 2022 at 03:04:34PM -0700, Andres Freund wrote:
> But mainly I'd expect to find a difference if the SIMD code were optimized a
> further on the basis of not needing to return the offset. E.g. by
> replacing _mm_packs_epi32 with _mm_or_si128, that's cheaper.

I haven't been able to find a significant difference between the two.  If
anything, the _mm_packs_epi* approach actually seems to be slightly faster
in some cases.  For something marginally more concrete, I compared the two
in perf-top and saw the following for the relevant instructions:

_mm_packs_epi*:
	0.19 │       packssdw   %xmm1,%xmm0
	0.62 │       packssdw   %xmm1,%xmm0
	7.14 │       packsswb   %xmm1,%xmm0

_mm_or_si128:
	1.52 │       por        %xmm1,%xmm0
	2.05 │       por        %xmm1,%xmm0
	5.66 │       por        %xmm1,%xmm0

I also tried a combined approach where I replaced _mm_packs_epi16 with
_mm_or_si128:
	1.16 │       packssdw   %xmm1,%xmm0
	1.47 │       packssdw   %xmm1,%xmm0
	8.17 │       por        %xmm1,%xmm0

Of course, this simplistic analysis leaves out the impact of the
surrounding instructions, but it seems to support the idea that the
_mm_packs_epi* approach might have a slight edge.

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com





view thread (48+ messages)  latest in thread

Message-ID: <20220806181326.GA1216305@nathanxps13>
Permalink:  ../20220806181326.GA1216305@nathanxps13/
Also on:    postgresql.org/message-id/20220806181326.GA1216305@nathanxps13

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: nathandbossart@gmail.com, andres@anarazel.de, john.naylor@enterprisedb.com, jcnaylor@gmail.com
  Subject: Re: optimize lookups in snapshot [sub]xip arrays
  In-Reply-To: <20220806181326.GA1216305@nathanxps13>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox