Re: Use pg_nextpower2_* in a few more places

2021-06-30 Thread David Rowley
On Sun, 13 Jun 2021 at 00:31, David Rowley wrote: > > Back in f0705bb62, we added pg_nextpower2_32 and pg_nextpower2_64 to > efficiently obtain the next power of 2 of a given number using an > intrinsic function to find the left-most 1 bit. > > In d025cf88b and 02a2e8b44, I added some usages of th

Re: Use pg_nextpower2_* in a few more places

2021-06-12 Thread Zhihong Yu
On Sat, Jun 12, 2021 at 7:35 AM David Rowley wrote: > On Sun, 13 Jun 2021 at 02:08, Zhihong Yu wrote: > > Maybe add an assertion after the assignment, that newalloc >= > LWLockTrancheNamesAllocated. > > I don't quite see how it would be possible for that to ever fail. I > could understand addin

Re: Use pg_nextpower2_* in a few more places

2021-06-12 Thread David Rowley
On Sun, 13 Jun 2021 at 02:08, Zhihong Yu wrote: > Maybe add an assertion after the assignment, that newalloc >= > LWLockTrancheNamesAllocated. I don't quite see how it would be possible for that to ever fail. I could understand adding an Assert() if some logic was outside the function and we w

Re: Use pg_nextpower2_* in a few more places

2021-06-12 Thread Zhihong Yu
On Sat, Jun 12, 2021 at 6:40 AM David Rowley wrote: > Thanks for having a look. > > On Sun, 13 Jun 2021 at 00:50, Zhihong Yu wrote: > > - newalloc = Max(LWLockTrancheNamesAllocated, 8); > > - while (newalloc <= tranche_id) > > - newalloc *= 2; > > + newalloc = pg_next

Re: Use pg_nextpower2_* in a few more places

2021-06-12 Thread David Rowley
Thanks for having a look. On Sun, 13 Jun 2021 at 00:50, Zhihong Yu wrote: > - newalloc = Max(LWLockTrancheNamesAllocated, 8); > - while (newalloc <= tranche_id) > - newalloc *= 2; > + newalloc = pg_nextpower2_32(Max(8, tranche_id + 1)); > > Should LWLockTrancheNamesAll

Re: Use pg_nextpower2_* in a few more places

2021-06-12 Thread Zhihong Yu
On Sat, Jun 12, 2021 at 5:32 AM David Rowley wrote: > Back in f0705bb62, we added pg_nextpower2_32 and pg_nextpower2_64 to > efficiently obtain the next power of 2 of a given number using an > intrinsic function to find the left-most 1 bit. > > In d025cf88b and 02a2e8b44, I added some usages of t

Use pg_nextpower2_* in a few more places

2021-06-12 Thread David Rowley
Back in f0705bb62, we added pg_nextpower2_32 and pg_nextpower2_64 to efficiently obtain the next power of 2 of a given number using an intrinsic function to find the left-most 1 bit. In d025cf88b and 02a2e8b44, I added some usages of these new functions but I didn't quite get all of them done. T