aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-11-18 11:44:11 +0900
committerMichael Paquier <michael@paquier.xyz>2024-11-18 11:52:35 +0900
commit03a42c9652f8cc2c447840e39418b862c48fd41d (patch)
tree11a1da99cf7a0e9c86f68ab8b8085470bd725a4f /src
parent5be1dabd2ae0cf48d927aad363c4b65507e38b25 (diff)
downloadpostgresql-03a42c9652f8cc2c447840e39418b862c48fd41d.tar.gz
postgresql-03a42c9652f8cc2c447840e39418b862c48fd41d.zip
Use pg_memory_is_all_zeros() in PageIsVerifiedExtended()
Relying on pg_memory_is_all_zeros(), which would apply SIMD instructions when dealing with an aligned page, is proving to be at least three times faster than the original size_t-based comparisons when checking if a BLCKSZ page is full of zeros. Note that PageIsVerifiedExtended() is called each time a page is read from disk, and making it faster is a good thing. Author: Bertrand Drouvot Discussion: https://postgr.es/m/CAApHDvq7P-JgFhgtxUPqhavG-qSDVUhyWaEX9M8_MNorFEijZA@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/storage/page/bufpage.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c
index be6f1f62d29..aa264f61b9c 100644
--- a/src/backend/storage/page/bufpage.c
+++ b/src/backend/storage/page/bufpage.c
@@ -89,10 +89,8 @@ 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;
/*
@@ -126,18 +124,9 @@ 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 (all_zeroes)
+ if (pg_memory_is_all_zeros(pagebytes, BLCKSZ))
return true;
/*