Re: define pg_structiszero(addr, s, r)

Bertrand Drouvot <bertranddrouvot.pg@gmail.com>

From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Ranier Vilela <ranier.vf@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, David Rowley <dgrowleyml@gmail.com>, Peter Smith <smithpb2250@gmail.com>, Peter Eisentraut <peter@eisentraut.org>, Heikki Linnakangas <hlinnaka@iki.fi>, pgsql-hackers@lists.postgresql.org
Date: 2024-11-13T06:41:08Z
Lists: pgsql-hackers
Hi,

On Tue, Nov 12, 2024 at 01:32:36PM -0300, Ranier Vilela wrote:
> It seems to me that it is enough to protect the SIMD loop when the size is
> smaller.
> 
>     if (len > sizeof(size_t) * 8)
>     {
>       for (; p < aligned_end - (sizeof(size_t) * 7); p += sizeof(size_t) *
> 8)
>       {
>           if ((((size_t *) p)[0] != 0) | (((size_t *) p)[1] != 0) |
>               (((size_t *) p)[2] != 0) | (((size_t *) p)[3] != 0) |
>               (((size_t *) p)[4] != 0) | (((size_t *) p)[5] != 0) |
>               (((size_t *) p)[6] != 0) | (((size_t *) p)[7] != 0))
>               return false;
>       }
>     }
> 
> See v1_allzeros_small.c attached.

Thanks for looking at it!

It's not enough, as that would not fix the second reason mentioned in [1].


[1]: https://www.postgresql.org/message-id/ZzLxAJuGzyqA7cUo%40ip-10-97-1-34.eu-west-3.compute.internal 


Regards,

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



Commits

  1. Use pg_memory_is_all_zeros() in PageIsVerifiedExtended()

  2. Optimize pg_memory_is_all_zeros() in memutils.h

  3. Remove use of pg_memory_is_all_zeros() in bufpage.c

  4. Add pg_memory_is_all_zeros() in memutils.h