Re: Checkpointer write combining

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Checkpointer write combining
Date: 2025-10-15 20:56:55
Message-ID: CAAKRu_b3k+KbeFhFgDZ26PvJbvL9W5HYwKrn8bBS4CTU13khpw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 11, 2025 at 11:33 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> I don’t understand why the two versions are different:
>
> if (XLogNeedsFlush(lsn))
> {
> /*
> * Remove the dirty buffer from the ring; necessary to prevent an
> * infinite loop if all ring members are dirty.
> */
> strategy->buffers[strategy->current] = InvalidBuffer;
> return true;
> }
>
> return false;
>
> VS
>
> if (XLogNeedsFlush(lsn))
> return false;

I think you mean
if (!XLogNeedsFlush(lsn))
{
return false;
}
// remove buffer
return true

is the same as

if (XLogNeedsFlush(lsn))
{
//remove dirty buffer
return true
}
return false;

Which is true. I've changed it to be like that.

Attached version 7 is rebased and has some bug fixes.

I also added a bonus batch on the end (0007) that refactors
SyncOneBuffer() to use the CAS loop pattern for pinning the buffer
that Andres introduced in 5e89985928795f243. bgwriter is now the only
user of SyncOneBuffer() and it rejects writing out buffers that are
used, so it seemed like a decent use case for this.

- Melanie

Attachment Content-Type Size
v7-0001-Refactor-goto-into-for-loop-in-GetVictimBuffer.patch text/x-patch 12.3 KB
v7-0002-Split-FlushBuffer-into-two-parts.patch text/x-patch 7.8 KB
v7-0003-Eagerly-flush-bulkwrite-strategy-ring.patch text/x-patch 12.7 KB
v7-0004-Write-combining-for-BAS_BULKWRITE.patch text/x-patch 16.5 KB
v7-0005-Add-database-Oid-to-CkptSortItem.patch text/x-patch 1.9 KB
v7-0006-Implement-checkpointer-data-write-combining.patch text/x-patch 10.8 KB
v7-0007-WIP-Refactor-SyncOneBuffer-for-bgwriter-only.patch text/x-patch 5.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2025-10-15 21:00:30 Re: Eagerly evict bulkwrite strategy ring
Previous Message Jeff Davis 2025-10-15 20:43:58 Re: make tsearch use the database default locale