Re: Compression of bigger WAL records

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Japin Li <japinli(at)hotmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, wenhui qiu <qiuwenhuifx(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Compression of bigger WAL records
Date: 2026-10-08 03:53:17
Message-ID: 5D6669EE-21FF-476A-9078-FF8BE9482AC5@yandex-team.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Michael!

On 8 Oct 2026, at 02:04 UTC, Michael Paquier wrote:
> Applied the recovery part.

Thank you for reviewing, benchmarking and committing it!

Interesting difference in our setups is libzstd: my has 1.5.5, while your
three machines use 1.5.7. I have not checked yet whether that explains the
larger gain here.

Attached is v11 with the three remaining patches, rebased on master:

0001 reuses the compression context on WAL insertion. I restored the
fallback to an uncompressed image if context allocation fails, rather
than risking a PANIC in a critical section.

0002 compresses whole records, allowing lz4 and zstd to share matches
across full-page images. It now reuses the committed reader context too.
The decompression buffer follows the reader's lifetime, and the reader
checks that decompression produces the declared length.

0003 keeps zstd history across records to reach small records that do
not compress well on their own. It is still WIP and off by default.
Reader memory use and the cost of rewinding to a reset boundary remain
the main trade-offs. The decompressors now have context-reset cleanup.

The allocation question from my previous mail is still open: 0002 needs
two buffers in place of the old per-image workspace. I have not found a
way to avoid the extra buffer without complicating the insertion path.

Thank you!

Best regards, Andrey Borodin.

Attachment Content-Type Size
v11-0001-Reuse-the-zstd-context-when-compressing-WAL-imag.patch application/octet-stream 2.3 KB
v11-0002-Add-whole-record-WAL-compression-alongside-FPI-c.patch application/octet-stream 54.0 KB
v11-0003-WIP-compress-WAL-records-against-earlier-records.patch application/octet-stream 66.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2026-10-08 03:58:00 Re: Two more RI fast-path issues
Previous Message shihao zhong 2026-10-08 03:33:31 [PG19] Wrong results from Memoize with a nondeterministic collation