Re: Add os_page_num to pg_buffercache

From: Mircea Cadariu <cadariu(dot)mircea(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add os_page_num to pg_buffercache
Date: 2025-07-09 09:51:16
Message-ID: fb2856ac-92bd-4a6b-adf9-89d7e0d8e0be@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Thanks for the prompt reply!

On 09/07/2025 08:37, Bertrand Drouvot wrote:
> Yeah, I tried to avoid code duplication for the "os pages" related stuff in
> v1. I can check if more can be done (outside of the "os pages" related stuff).
>
> Might be done in a dedicated patch though, I mean I don't think that should be
> a blocker for this one.

Agreed, if there's any low-hanging fruit to address now that this file
is cracked open, then great. Otherwise, makes sense to leave it for a
separate dedicated patch.

If you don't mind I have some further questions on the patch, see below.

> + if (get_call_result_type(fcinfo, NULL, &expected_tupledesc) != TYPEFUNC_COMPOSITE)
> + elog(ERROR, "return type must be a row type");

Is this needed in the new pg_buffercache_os_pages function? I noticed
this check also in the "original" pg_buffercache_pages. There's a
comment there indicating that (if I understand correctly) its purpose is
to handle upgrades from version 1.0, mentioning a field unrelated to
this patch.

If it's needed, shall we consider adding a similar comment as
in pg_buffercache_pages?

> + /*
> + * Different database block sizes (4kB, 8kB, ..., 32kB) can be used,
> + * while the OS may have different memory page sizes.
> + *
> + * To correctly map between them, we need to: 1. Determine the OS
> + * memory page size 2. Calculate how many OS pages are used by all
> + * buffer blocks 3. Calculate how many OS pages are contained within
> + * each database block.
> + */
For step number 3 - should it be the other way around: database blocks
are contained within OS pages?

Kind regards,

Mircea Cadariu

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jakub Wartak 2025-07-09 10:04:00 Re: Adding basic NUMA awareness
Previous Message Dean Rasheed 2025-07-09 09:38:31 Re: Improving and extending int128.h to more of numeric.c