pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix poorly-sized buffers in astreamer compression modules.
Date: Tue, 24 Mar 2026 16:17:21 +0000
Message-ID: <E1w54RV-001G7r-06@gemulon.postgresql.org> (raw)

Fix poorly-sized buffers in astreamer compression modules.

astreamer_gzip.c and astreamer_lz4.c left their decompression
output buffers at StringInfo's default allocation, merely 1kB.
This results in a lot of ping-ponging between the decompressor
and the next astreamer filter.  This patch increases these buffer
sizes to 256kB.  In a simple test this had a small but measurable
effect (saving a few percent) on the overall runtime of pg_waldump
for the gzipped-data case; I didn't bother measuring for lz4.

astreamer_zstd.c used ZSTD_DStreamOutSize() to size its
compression output buffer, but the libzstd API says you should use
ZSTD_CStreamOutSize(); ZSTD_DStreamOutSize() is for decompression.
The two functions seem to produce the same value (256kB) here, so
this is just cosmetic, but nonetheless we should play by the rules.

While these issues are old, they don't seem significant enough to
warrant back-patching.

Discussion: https://postgr.es/m/3424809.1774234940@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6e243d81c54966e640870c96d73576376ec125c6

Modified Files
--------------
src/fe_utils/astreamer_gzip.c | 2 ++
src/fe_utils/astreamer_lz4.c  | 2 ++
src/fe_utils/astreamer_zstd.c | 2 +-
3 files changed, 5 insertions(+), 1 deletion(-)



Message-ID: <E1w54RV-001G7r-06@gemulon.postgresql.org>
Permalink:  ../E1w54RV-001G7r-06@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w54RV-001G7r-06@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix poorly-sized buffers in astreamer compression modules.
  In-Reply-To: <E1w54RV-001G7r-06@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox