From: | Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru> |
---|---|
To: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Cc: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru> |
Subject: | Fix bank selection logic in SLRU |
Date: | 2024-12-10 12:39:28 |
Message-ID: | 9444dc46-ca47-43ed-9058-89c456316306@postgrespro.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Good day, hackers.
Due to long discussion about SLRU size configuration [1] and code
evolution, non-serious bug were introduced:
- intermediate versions assumed cache size is always power of 2,
- therefore to determine bank simple binary-and with mask were used:
bankno = pageno & ctl->bank_mask;
- final merged version allows arbitrary cache size for every cache
type, but code for bankno were not fixed.
It is not critical bug, since it doesn't hurt correctness just
performance. In worst case only one bank will be used.
I attach the patch, that changes SlruCtlData->bank_mask to ->nbanks,
and changes calculation to modulo operation.
bankno = pageno % ctl->nbanks;
Probably, instead of modulo operation could be used multiplication:
bankno = ((uint64) murmurhash32(pageno) * ctl->nbanks) >> 32;
But I didn't bother to measure does it pay for or not.
Regards,
Yura Sokolov aka funny-falcon
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Fix-SLRU-bank-selection.patch | text/x-patch | 2.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrey M. Borodin | 2024-12-10 12:56:06 | Re: bt_index_parent_check and concurrently build indexes |
Previous Message | Guillaume Lelarge | 2024-12-10 12:22:38 | Re: Proposals for EXPLAIN: rename ANALYZE to EXECUTE and extend VERBOSE |