From: Justin Pryzby Date: Thu, 30 Mar 2023 17:48:57 -0500 Subject: [PATCH 3/4] WIP: pg_dump: support zstd workers This is a separate commit since it's not essential; the zstd library is frequently compiled without threading support, so the functionality isn't very well-tested, and because use of zstd threads might conceivably play poorly with pg_dump's use of threads under Windows. Targetting postgres v17. --- doc/src/sgml/ref/pg_dump.sgml | 8 ++++++-- src/bin/pg_dump/compress_zstd.c | 4 ++++ src/bin/pg_dump/pg_dump.c | 4 ---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index e81e35c13b3..1d55ce05b21 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -681,8 +681,12 @@ PostgreSQL documentation as though it had been fed through gzip, lz4, or zstd; but the default is not to compress. - With zstd compression, long mode may improve the - compression ratio, at the cost of increased memory use. + With zstd compression, long and + workers options may be specified to enable long-distance + matching and threaded workers, respectively. + Long distance mode may improve the compression ratio, at the cost of + increased memory use. + Threaded workers allow leveraging multiple CPUs during compression. The tar archive format currently does not support compression at all. diff --git a/src/bin/pg_dump/compress_zstd.c b/src/bin/pg_dump/compress_zstd.c index 49a877ce010..f1f84ad69c4 100644 --- a/src/bin/pg_dump/compress_zstd.c +++ b/src/bin/pg_dump/compress_zstd.c @@ -85,6 +85,10 @@ _ZstdCStreamParams(pg_compress_specification compress) ZSTD_c_enableLongDistanceMatching, compress.long_distance, "long"); + if (compress.options & PG_COMPRESSION_OPTION_WORKERS) + _Zstd_CCtx_setParam_or_die(cstream, ZSTD_c_nbWorkers, + compress.workers, "workers"); + return cstream; } diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index a426984046b..240dcdb0223 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -740,10 +740,6 @@ main(int argc, char **argv) if (error_detail != NULL) pg_fatal("%s", error_detail); - if (compression_spec.options & PG_COMPRESSION_OPTION_WORKERS) - pg_log_warning("compression option \"%s\" is not currently supported by pg_dump", - "workers"); - /* * Custom and directory formats are compressed by default with gzip when * available, not the others. -- 2.34.1 --cM8PVdkeIMgUsrHS Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0004-TMP-pg_dump-use-Zstd-by-default-for-CI-only.patch"