Re: define pg_structiszero(addr, s, r)

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: define pg_structiszero(addr, s, r)
Date: 2024-11-07 08:41:34
Message-ID: Zyx9PhpGFKFktn9M@ip-10-97-1-34.eu-west-3.compute.internal
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thu, Nov 07, 2024 at 09:44:32AM +0900, Michael Paquier wrote:
> On Thu, Nov 07, 2024 at 08:10:17AM +1300, David Rowley wrote:
> > Did you try with a size where there's a decent remainder, say 124
> > bytes? FWIW, one of the cases has 112 bytes, and I think that is
> > aligned memory meaning we'll do the first 64 in the SIMD loop and have
> > to do 48 bytes in the byte-at-a-time loop. If you had the loop Michael
> > mentioned, that would instead be 6 loops of size_t-at-a-time.
>
> See the attached allzeros.c, based on the previous versions exchanged.
> And now just imagine a structure like that:
> #define BLCKSZ 48
> typedef union AlignedBlock
> {
> char data[BLCKSZ];
> double force_align_d;
> int64_t force_align_i64;
> } AlignedBlock;
>
> The allzero check is used for pgstat entries, and it could be possible
> that some out-of-core code needs to rely on such small-ish sizes, or
> even something else when a patch author feels like it. So let's make
> that optimized as much as we think we can: that's what this discussion
> is about.

Yeah, fully agree. My initial testing was not "good" enough and so was not showing
as much improvement as your's and David's ones.

Please find v8 attached.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v8-0001-Optimize-pg_memory_is_all_zeros.patch text/x-diff 4.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2024-11-07 08:41:52 Re: define pg_structiszero(addr, s, r)
Previous Message Andrey M. Borodin 2024-11-07 08:34:14 Re: UUID v7