Re: RFC: Packing the buffer lookup table

From: Andres Freund <andres(at)anarazel(dot)de>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, James Hunter <james(dot)hunter(dot)pg(at)gmail(dot)com>, Zhang Mingli <zmlpostgres(at)gmail(dot)com>
Subject: Re: RFC: Packing the buffer lookup table
Date: 2025-02-05 01:22:15
Message-ID: 2vo2q27np37lao5334rbrftgnmvg46kex6vtdnwak6tln3juxi@flyeydrgilc7
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2025-02-04 19:58:36 +0100, Matthias van de Meent wrote:
> On Thu, 30 Jan 2025 at 08:48, Matthias van de Meent
> <boekewurm+postgres(at)gmail(dot)com> wrote:
> >
> > Together that results in the following prototype patchset.
>
> Here's an alternative patch, which replaces dynahash in the buffer
> lookup table with an open-coded replacement that has fewer
> indirections during lookups, and allows for a much increased locality.
>
> Overall, it has less memory usage than our current dynahash in all
> cases; but compared to my previous patch it improves memory only in
> some cases, in others it uses more memory.
>
> The main design is a separate chaining hash table (similar to and
> derived from code of Dynahash) to provide efficient access to free
> elements.

Why do you want to use a separate chaining hash table? For something as
performance sensitive as this the lower cache hit ratio seems like a strong
reason to not go for such a hash table "architecture"?

I think it'd be better to work towards not using a hash table for the buffer
mapping table than to write a dedicated hash table implementation for it
though. A hash table

a) doesn't have ordered access support, which causes a bunch of O(NBuffers)
operations and makes things like readahead etc way more expensive
b) doesn't benefit from spatial locality, even though buffer lookups have a
very high degree of spatial locality

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-02-05 01:31:46 Re: [PATCH] Optionally record Plan IDs to track plan changes for a query
Previous Message Andres Freund 2025-02-05 01:14:17 Re: RFC: Packing the buffer lookup table