Re: [RFC] Lock-free XLog Reservation from WAL

From: Japin Li <japinli(at)hotmail(dot)com>
To: Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru>
Cc: "Zhou, Zhiguo" <zhiguo(dot)zhou(at)intel(dot)com>, wenhui qiu <qiuwenhuifx(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [RFC] Lock-free XLog Reservation from WAL
Date: 2025-01-23 08:46:44
Message-ID: ME0P300MB04457609EB0660D27DC6BCE6B6E02@ME0P300MB0445.AUSP300.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 22 Jan 2025 at 22:44, Japin Li <japinli(at)hotmail(dot)com> wrote:
> On Wed, 22 Jan 2025 at 17:02, Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru> wrote:
>> I believe, I know why it happens: I was in hurry making v2 by
>> cherry-picking internal version. I reverted some changes in
>> CalcCuckooPositions manually and forgot to add modulo
>> PREV_LINKS_HASH_CAPA.
>>
>> Here's the fix:
>>
>> pos->pos[0] = hash % PREV_LINKS_HASH_CAPA;
>> - pos->pos[1] = pos->pos[0] + 1;
>> + pos->pos[1] = (pos->pos[0] + 1) % PREV_LINKS_HASH_CAPA;
>> pos->pos[2] = (hash >> 16) % PREV_LINKS_HASH_CAPA;
>> - pos->pos[3] = pos->pos[2] + 2;
>> + pos->pos[3] = (pos->pos[2] + 2) % PREV_LINKS_HASH_CAPA;
>>
>> Any way, here's v3:
>> - excess file "v0-0001-Increase..." removed. I believe it was source
>> of white-space apply warnings.
>> - this mistake fixed
>> - more clear slots strategies + "8 positions in two cache-lines" strategy.
>>
>> You may play with switching PREV_LINKS_HASH_STRATEGY to 2 or 3 and see
>> if it affects measurably.
>
> Thanks for your quick fixing. I will retest it tomorrow.

Hi, Yura Sokolov

Here is my test result of the v3 patch:

| case | min | avg | max |
|-------------------------------+------------+------------+------------|
| master (44b61efb79) | 865,743.55 | 871,237.40 | 874,492.59 |
| v3 | 857,020.58 | 860,180.11 | 864,355.00 |
| v3 PREV_LINKS_HASH_STRATEGY=2 | 853,187.41 | 855,796.36 | 858,436.44 |
| v3 PREV_LINKS_HASH_STRATEGY=3 | 863,131.97 | 864,272.91 | 865,396.42 |

It seems there are some performance decreases :( or something I missed?

--
Regrads,
Japin Li

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Frédéric Yhuel 2025-01-23 09:00:27 Re: doc: explain pgstatindex fragmentation
Previous Message Ilia Evdokimov 2025-01-23 08:46:29 Re: Sample rate added to pg_stat_statements