> On 14 Dec 2023, at 08:12, Amul Sul <sula...@gmail.com> wrote: > > > + int bankno = pageno & ctl->bank_mask; > > I am a bit uncomfortable seeing it as a mask, why can't it be simply a number > of banks (num_banks) and get the bank number through modulus op (pageno % > num_banks) instead of bitwise & operation (pageno & ctl->bank_mask) which is a > bit difficult to read compared to modulus op which is quite simple, > straightforward and much common practice in hashing. > > Are there any advantages of using & over % ? The instruction AND is ~20 times faster than IDIV [0]. This is relatively hot function, worth sacrificing some readability to save ~ten nanoseconds on each check of a status of a transaction. [0] https://www.agner.org/optimize/instruction_tables.pdf
- Re: SLRU optimization - configurable buffer poo... Alvaro Herrera
- Re: SLRU optimization - configurable buffer... Dilip Kumar
- Re: SLRU optimization - configurable bu... Andrey M. Borodin
- Re: SLRU optimization - configurab... Dilip Kumar
- Re: SLRU optimization - config... Dilip Kumar
- Re: SLRU optimization - config... Dilip Kumar
- Re: SLRU optimization - config... tender wang
- Re: SLRU optimization - config... Alvaro Herrera
- Re: SLRU optimization - config... Dilip Kumar
- Re: SLRU optimization - config... Amul Sul
- Re: SLRU optimization - config... Andrey M. Borodin
- Re: SLRU optimization - config... tender wang
- Re: SLRU optimization - config... Andrey M. Borodin
- Re: SLRU optimization - config... tender wang
- Re: SLRU optimization - config... Andrey M. Borodin
- Re: SLRU optimization - configurable buffer poo... Andrey M. Borodin
- Re: SLRU optimization - configurable buffer... Dilip Kumar
- Re: SLRU optimization - configurable buffer pool and par... Alvaro Herrera
- Re: SLRU optimization - configurable buffer pool an... Dilip Kumar
- Re: SLRU optimization - configurable buffer poo... Alvaro Herrera
- Re: SLRU optimization - configurable buffer pool and par... Alvaro Herrera