Re: define pg_structiszero(addr, s, r)
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>,
Peter Smith <smithpb2250@gmail.com>
Cc: Peter Eisentraut <peter@eisentraut.org>,
pgsql-hackers@lists.postgresql.org
Date: 2024-10-29T09:39:03Z
Lists: pgsql-hackers
On 29/10/2024 09:54, Bertrand Drouvot wrote: >> https://godbolt.org/z/x9hPWjheq. > > Yeah, I also think that's fine. Peter Smith did some testing in [1] comparing > memcmp and simple loop checking (thanks Peter for the testing!): > > " > Iterate 1000000 times... > check zeros using loop -- elapsed=0.041196s > check zeros using memcmp -- elapsed=0.016407s > " > > So, in this test, the loop is 0.024789s longer means 0.024789s/1000000=24 Nanosecond > slower per comparison (If my math is correct). I believe that test program is bogus. Look at the assembly code; the compiler optimized away the loops. -- Heikki Linnakangas Neon (https://neon.tech)
Commits
-
Use pg_memory_is_all_zeros() in PageIsVerifiedExtended()
- 03a42c9652f8 18.0 landed
-
Optimize pg_memory_is_all_zeros() in memutils.h
- 5be1dabd2ae0 18.0 landed
-
Remove use of pg_memory_is_all_zeros() in bufpage.c
- e819bbb7c82a 18.0 landed
-
Add pg_memory_is_all_zeros() in memutils.h
- 07e9e28b56db 18.0 landed