| From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> | 
|---|---|
| To: | John Naylor <johncnaylorls(at)gmail(dot)com> | 
| Cc: | Ants Aasma <ants(at)cybertec(dot)at>, pgsql-hackers(at)postgresql(dot)org | 
| Subject: | Re: add AVX2 support to simd.h | 
| Date: | 2024-03-20 19:55:13 | 
| Message-ID: | 20240320195513.GA1618413@nathanxps13 | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
On Wed, Mar 20, 2024 at 09:31:16AM -0500, Nathan Bossart wrote:
> On Wed, Mar 20, 2024 at 01:57:54PM +0700, John Naylor wrote:
>> On Tue, Mar 19, 2024 at 11:30 PM Nathan Bossart
>> <nathandbossart(at)gmail(dot)com> wrote:
>>> I tried to trim some of the branches, and came up with the attached patch.
>>> I don't think this is exactly what you were suggesting, but I think it's
>>> relatively close.  My testing showed decent benefits from using 2 vectors
>>> when there aren't enough elements for 4, so I've tried to keep that part
>>> intact.
>> 
>> I would caution against that if the benchmark is repeatedly running
>> against a static number of elements, because the branch predictor will
>> be right all the time (except maybe when it exits a loop, not sure).
>> We probably don't need to go to the trouble to construct a benchmark
>> with some added randomness, but we have be careful not to overfit what
>> the test is actually measuring.
> 
> I don't mind removing the 2-register stuff if that's what you think we
> should do.  I'm cautiously optimistic that it'd help more than the extra
> branch prediction might hurt, and it'd at least help avoid regressing the
> lower end for the larger AVX2 registers, but I probably won't be able to
> prove that without constructing another benchmark.  And TBH I'm not sure
> it'll significantly impact any real-world workload, anyway.
Here's a new version of the patch set with the 2-register stuff removed,
plus a fresh run of the benchmark.  The weird spike for AVX2 is what led me
down the 2-register path earlier.
-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
| Attachment | Content-Type | Size | 
|---|---|---|
| v5-0001-pg_lfind32-add-overlap-code-for-remaining-element.patch | text/x-diff | 3.7 KB | 
| v5-0002-Add-support-for-AVX2-in-simd.h.patch | text/x-diff | 4.8 KB | 
|   | image/jpeg | 26.0 KB | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Banck | 2024-03-20 19:55:16 | Re: Possibility to disable `ALTER SYSTEM` | 
| Previous Message | Robert Haas | 2024-03-20 19:52:04 | Re: Possibility to disable `ALTER SYSTEM` |