Hi. Em seg., 4 de nov. de 2024 às 14:18, Bertrand Drouvot < bertranddrouvot...@gmail.com> escreveu:
> Hi, > > On Tue, Nov 05, 2024 at 12:24:48AM +1300, David Rowley wrote: > > On Sat, 2 Nov 2024 at 01:50, Bertrand Drouvot > > <bertranddrouvot...@gmail.com> wrote: > > > > > > On Fri, Nov 01, 2024 at 09:47:05PM +1300, David Rowley wrote: > > > > I've attached what I thought a more optimal version might look like > in > > > > case anyone thinks making it better is a good idea. > > > > > > > > > > Thanks for the proposal! > > > > > > I like the idea, I think that's worth to add a few comments, something > like: > > > > I'm happy if you want to pick this up and continue working on it. > > Sure, please find attached v1, the changes are: > > - switch from "const char" to "const unsigned char" (could have been done > in the > current version of pg_memory_is_all_zeros() though) > - added some comments > - adding an Assert for ptr != 0 > - re-introduce the function call in PageIsVerifiedExtended() > - propose a commit message > I think we can add a small optimization to this last patch [1]. The variable *aligned_end* is only needed in the second loop (for). So, only before the for loop do we actually declare it. Result before this change: check zeros using BERTRAND 1 0.000031s Result after this change: check zeros using BERTRAND 1 0.000018s + const unsigned char *aligned_end; + /* Multiple bytes comparison(s) at once */ + aligned_end = (const unsigned char *) ((uintptr_t) end & (~(sizeof(size_t) - 1))); + for (; p < aligned_end; p += sizeof(size_t)) best regards, Ranier Vilela [1] https://godbolt.org/z/fvdzjbnc7