Re: SLRU optimization - configurable buffer pool and partitioning the SLRU lock

From: "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>
To: tender wang <tndrwang(at)gmail(dot)com>
Cc: Amul Sul <sulamul(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: SLRU optimization - configurable buffer pool and partitioning the SLRU lock
Date: 2023-12-14 09:35:37
Message-ID: BB82F9C5-C12D-4D05-ADEA-1F89AA85C614@yandex-team.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 14 Dec 2023, at 14:28, tender wang <tndrwang(at)gmail(dot)com> wrote:
>
> Now that AND is more faster, Can we replace the '% SLRU_MAX_BANKLOCKS' operation in SimpleLruGetBankLock() with '& 127'

unsigned int GetBankno1(unsigned int pageno) {
return pageno & 127;
}

unsigned int GetBankno2(unsigned int pageno) {
return pageno % 128;
}

Generates with -O2

GetBankno1(unsigned int):
mov eax, edi
and eax, 127
ret
GetBankno2(unsigned int):
mov eax, edi
and eax, 127
ret

Compiler is smart enough with constants.

Best regards, Andrey Borodin.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sutou Kouhei 2023-12-14 09:44:14 Re: Make COPY format extendable: Extract COPY TO format implementations
Previous Message tender wang 2023-12-14 09:28:01 Re: SLRU optimization - configurable buffer pool and partitioning the SLRU lock