Re: [PING] [PATCH v2] parallel pg_restore: avoid disk seeks when jumping short distance forward

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dimitrios Apostolou <jimis(at)gmx(dot)net>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PING] [PATCH v2] parallel pg_restore: avoid disk seeks when jumping short distance forward
Date: 2025-10-11 02:22:16
Message-ID: 3698234.1760149336@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> I'm tempted to increase DEFAULT_IO_BUFFER_SIZE so that gzip
> also produces blocks in the vicinity of 64K, but we'd have
> to decouple the behavior of compress_lz4.c somehow, or it
> would want to produce blocks around a megabyte which might
> be excessive. (Or if it's not, we'd still want all these
> compression methods to choose similar block sizes, I'd think.)

After a bit of further experimentation, here is a v2 patchset.

0001 is like my previous patch except that it also fixes
Zstd_write and Zstd_close so that the "stream API" code doesn't
behave differently from the older API. Also, now with draft
commit message.

0002 adjusts things so that lz4 and gzip compression produce
block sizes around 128K, which is what compress_zstd.c already
does after 0001. While I wouldn't necessarily follow zstd's
lead if it were easy to do differently, it isn't. We'd have
to ignore ZSTD_CStreamOutSize() in favor of making our own
buffer size choice. That seems to carry some risks of tickling
bugs that upstream isn't testing for, and the value of 128K is
not so far off that I care to take any such risk.

This brings us to a place where all three compression modes
should yield roughly-comparable data block sizes, which is a good
starting point for further discussion of whether pg_restore needs
seek-versus-read adjustments.

regards, tom lane

Attachment Content-Type Size
v2-0001-Fix-poor-buffering-logic-in-pg_dump-s-lz4-and-zst.patch text/x-diff 13.5 KB
v2-0002-Try-to-align-the-block-sizes-of-pg_dump-s-various.patch text/x-diff 3.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Jeff Davis 2025-10-11 02:06:02 Re: new environment variable INITDB_LOCALE_PROVIDER