Re: Reduce padding in WALOpenSegment and XLogReaderState

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Reduce padding in WALOpenSegment and XLogReaderState
Date: 2026-08-14 10:28:13
Message-ID: an7qwjaCksFBqIms@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

On 2026-Aug-14, Japin Li wrote:

> Hi, hackers
>
> While reviewing patch [1], I noticed that we can reduce padding in both
> WALOpenSegment and XLogReaderState by reordering a few fields.

What do you think of the idea of changing segcxt so that the directory
name can be allocated to the length of the given directory instead of
the full MAXPGPATH? We could make ws_dir a pointer that goes just
beyond the end of the struct's sizeof, so that it's all still a single
palloc chunk. That would probably be a more significant memory savings
improvement. (Now, xlogreader is not allocated in huge numbers, so
saving a few hundred bytes is not terribly exciting in any case. But
maybe there are cases where XLogReadRecord shows in profile enough to
make it useful for XLogReaderState to fit better in CPU caches? I kinda
doubt this whole thing is worth it, but maybe you know of some.)

Regards

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message shveta malik 2026-08-14 10:22:49 Re: Support EXCEPT for TABLES IN SCHEMA publications