Remove use of pg_memory_is_all_zeros() in bufpage.c
authorMichael Paquier <michael@paquier.xyz>
Fri, 1 Nov 2024 08:05:36 +0000 (17:05 +0900)
committerMichael Paquier <michael@paquier.xyz>
Fri, 1 Nov 2024 08:05:36 +0000 (17:05 +0900)
After a closer lookup, this makes the all-zero check of the page more
expensive, so let's remove the new function call in bufpage.c.  The
maths of the check were also incorrect, checking that the page was full
of zeros only for the first 1kB.

This brings back the code to the state it was at 49d6c7d8daba.

Per discussion with David Rowley and Bertrand Drouvot.

Discussion: https://postgr.es/m/CAApHDvrXzPAr3FxoBuB7b3D-okNoNA2jxLun1rW8Yw5wkbqusw@mail.gmail.com

src/backend/storage/page/bufpage.c

index 5ee1e58cd440abc034446714f7acf12fad3cdac9..be6f1f62d292f2b13c6bdc0aebaa90f80d7e4620 100644 (file)
@@ -89,8 +89,10 @@ PageIsVerifiedExtended(Page page, BlockNumber blkno, int flags)
 {
        PageHeader      p = (PageHeader) page;
        size_t     *pagebytes;
+       int                     i;
        bool            checksum_failure = false;
        bool            header_sane = false;
+       bool            all_zeroes = false;
        uint16          checksum = 0;
 
        /*
@@ -124,9 +126,18 @@ PageIsVerifiedExtended(Page page, BlockNumber blkno, int flags)
        }
 
        /* Check all-zeroes case */
+       all_zeroes = true;
        pagebytes = (size_t *) page;
+       for (i = 0; i < (BLCKSZ / sizeof(size_t)); i++)
+       {
+               if (pagebytes[i] != 0)
+               {
+                       all_zeroes = false;
+                       break;
+               }
+       }
 
-       if (pg_memory_is_all_zeros(pagebytes, (BLCKSZ / sizeof(size_t))))
+       if (all_zeroes)
                return true;
 
        /*