Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 03a42c9

Browse files
committed
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
1 parent 5be1dab commit 03a42c9

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/backend/storage/page/bufpage.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ PageIsVerifiedExtended(Page page, BlockNumber blkno, int flags)
8989
{
9090
PageHeader p = (PageHeader) page;
9191
size_t *pagebytes;
92-
int i;
9392
bool checksum_failure = false;
9493
bool header_sane = false;
95-
bool all_zeroes = false;
9694
uint16 checksum = 0;
9795

9896
/*
@@ -126,18 +124,9 @@ PageIsVerifiedExtended(Page page, BlockNumber blkno, int flags)
126124
}
127125

128126
/* Check all-zeroes case */
129-
all_zeroes = true;
130127
pagebytes = (size_t *) page;
131-
for (i = 0; i < (BLCKSZ / sizeof(size_t)); i++)
132-
{
133-
if (pagebytes[i] != 0)
134-
{
135-
all_zeroes = false;
136-
break;
137-
}
138-
}
139128

140-
if (all_zeroes)
129+
if (pg_memory_is_all_zeros(pagebytes, BLCKSZ))
141130
return true;
142131

143132
/*

0 commit comments

Comments
 (0)