Re: Do away with zero-padding assumption before WALRead()

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Do away with zero-padding assumption before WALRead()
Date: 2024-02-16 14:10:00
Message-ID: CALj2ACWUaXCif2hXUsV8iitcgKTzd4gS_7KJ-pVtd=ZTMUNGJA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Feb 15, 2024 at 3:49 PM Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com> wrote:
>
> > I'm wondering why the WALRead() callers are always reading XLOG_BLCKSZ
> > despite knowing exactly how much to read. Is it to tell the OS to
> > explicitly fetch the whole page from the disk? If yes, the OS will do
> > that anyway because the page transfers from disk to OS page cache are
> > always in terms of disk block sizes, no?
>
> I am curious about the same. The page size and disk block size could
> be different,

Yes, they can be different, but.... (see below)

> so the reason could be explicitly fetching the whole
> page from the disk as you said.

Upon OS page cache miss, the whole page (of disk block size) gets
fetched from disk even if we just read 'count' bytes (< disk block
size), no? This is my understanding about page transfers between disk
and OS page cache.

> Is this the reason or are there any
> other benefits of always reading XLOG_BLCKSZ instead of reading the
> sufficient part? I tried to search in older threads and code comments
> but I could not find an explanation.

FWIW, walsender for physical replication will just read as much as it
wants to read which can range from WAL of size < XLOG_BLCKSZ to
MAX_SEND_SIZE (XLOG_BLCKSZ * 16). I mean, it does not read the whole
page of bytes XLOG_BLCKSZ when it wants to read < XLOG_BLCKSZ.

--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2024-02-16 14:20:00 Re: Do away with zero-padding assumption before WALRead()
Previous Message Daniel Gustafsson 2024-02-16 13:30:38 Re: Replace current implementations in crypt() and gen_salt() to OpenSSL