Re: [PATCHES] Post-special page storage TDE support

From: David Christensen <david(dot)christensen(at)crunchydata(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Stephen Frost <sfrost(at)snowman(dot)net>
Subject: Re: [PATCHES] Post-special page storage TDE support
Date: 2023-12-22 21:24:50
Message-ID: CAOxo6XKGvWoeRinfGHPe1VrNj7t8_JabDQ-tJyt8ChS6wmwKOw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi again!

Per some offline discussion with Stephen, I've continued to work on some
modifications here; this particular patchset is intended to facilitate
review by highlighting the mechanical nature of many of these changes. As
such, I have taken the following approach to this rework:

0001 - Create PageUsableSpace to represent space post-smgr
0002 - Add support for fast, non-division-based div/mod algorithms
0003 - Use fastdiv code in visibility map
0004 - Make PageUsableSpace incorporate variable-sized limit
0005 - Add Calc, Limit and Dynamic forms of all variable constants
0006 - Split MaxHeapTuplesPerPage into Limit and Dynamic variants
0007 - Split MaxIndexTuplesPerPage into Limit and Dynamic variants
0008 - Split MaxHeapTupleSize into Limit and Dynamic variants
0009 - Split MaxTIDsPerBTreePage into Limit and Dynamic variant

0001 - 0003 have appeared in this thread or in other forms on the list
already, though 0001 refactors things slightly more aggressively, but makes
StaticAssert() to ensure that this change is still sane.

0004 adds the ReservedPageSpace variable, and also redefines the previous
BLCKSZ - SizeOfPageHeaderDate as PageUsableSpaceMax; there are a few
related fixups.

0005 adds the macros to compute the former constants while leaving their
original definitions to evaluate to the same place (the infamous Calc* and
*Limit, plus we invite *Dynamic to the party as well; the names are
terrible and there must be something better)

0006 - 0009 are all the same approach; we undefine the old constant name
and modify the existing uses of this symbol to be either the *Limit or
*Dynamic, depending on if the changed available space would impact the
calculations. Since we are touching every use of this symbol, this
facilitates review of the impact, though I would contend that almost every
piece I've spot-checked seems like it really does need to know about the
runtime limit. Perhaps there is more we could do here. I could also see a
variable per constant rather than recalculating this every time, in which
case the *Dynamic would just be the variable and we'd need a hook to
initialize this or otherwise set on first use.

There are a number of additional things remaining to be done to get this to
fully work, but I did want to get some of this out there for review.

Still to do (almost all in some form in original patch, so just need to
extract the relevant pieces):
- set reserved-page-size via initdb
- load reserved-page-size from pg_control
- apply to the running cluster
- some form of compatibility for these constants in common and ensuring
bin/ works
- some toast-related changes (this requires a patch to support dynamic
relopts, which I can extract, as the existing code is using a constant
lookup table)
- probably some more pieces I'm forgetting

Thanks,
David

Attachment Content-Type Size
v2-0005-Add-Calc-Limit-and-Dynamic-forms-of-all-variable-.patch application/octet-stream 5.7 KB
v2-0001-Create-PageUsableSpace-to-represent-space-post-sm.patch application/octet-stream 15.0 KB
v2-0002-Add-support-for-fast-non-division-based-div-mod-a.patch application/octet-stream 1.7 KB
v2-0003-Use-fastdiv-code-in-visibility-map.patch application/octet-stream 7.1 KB
v2-0004-Make-PageUsableSpace-incorporate-variable-sized-l.patch application/octet-stream 1.9 KB
v2-0007-Split-MaxIndexTuplesPerPage-into-Limit-and-Dynami.patch application/octet-stream 17.7 KB
v2-0008-Split-MaxHeapTupleSize-into-Limit-and-Dynamic-var.patch application/octet-stream 9.2 KB
v2-0006-Split-MaxHeapTuplesPerPage-into-Limit-and-Dynamic.patch application/octet-stream 22.8 KB
v2-0009-Split-MaxTIDsPerBTreePage-into-Limit-and-Dynamic-.patch application/octet-stream 6.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2023-12-22 21:33:18 Re: Make all Perl warnings fatal
Previous Message Peter Eisentraut 2023-12-22 21:01:01 Re: Set all variable-length fields of pg_attribute to null on column drop