Re: optimize lookups in snapshot [sub]xip arrays

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>, John Naylor <jcnaylor(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: optimize lookups in snapshot [sub]xip arrays
Date: 2022-08-06 18:13:26
Message-ID: 20220806181326.GA1216305@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-08-06 19:01:58 Re: pgsql: BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking
Previous Message Tom Lane 2022-08-06 16:59:24 conchuela doesn't like gnu_printf anymore