agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH 09/10] Add zstd compression levels 78+ messages / 3 participants [nested] [flat]
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5a8447a525..2c6c97c1b3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --0qVF/w3MHQqLSynd-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 15 +++++++++++++-- src/backend/access/transam/xlogreader.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4591e476c6..4f11f96373 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -915,11 +915,22 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, - ZSTD_CLEVEL_DEFAULT); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len, level); if (ZSTD_isError(len)) len = -1; break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 0f9d522087..0de61d3073 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1554,6 +1554,10 @@ struct walcompression walmethods[] = { {"zlib", WAL_COMPRESSION_ZLIB}, {"lz4", WAL_COMPRESSION_LZ4}, {"zstd", WAL_COMPRESSION_ZSTD}, + {"zstd-1", WAL_COMPRESSION_ZSTD}, + {"zstd-fast-10",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-20",WAL_COMPRESSION_ZSTD}, + {"zstd-fast-40",WAL_COMPRESSION_ZSTD}, }; /* @@ -1628,6 +1632,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + /* + * There aren't actually written into the header - decompression is the + * same. + * case WAL_COMPRESSION_ZSTD_1: + * case WAL_COMPRESSION_ZSTD_FAST_10: + * case WAL_COMPRESSION_ZSTD_FAST_20: + * case WAL_COMPRESSION_ZSTD_FAST_40: + */ decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa8146645d..a435b1a654 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -338,6 +338,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --jozmn01XJZjDjM3N-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* [PATCH 09/10] Add zstd compression levels @ 2021-03-14 22:12 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: Justin Pryzby @ 2021-03-14 22:12 UTC (permalink / raw) --- src/backend/access/transam/xlog.c | 6 +++++- src/backend/access/transam/xloginsert.c | 14 +++++++++++++- src/backend/access/transam/xlogreader.c | 8 ++++++++ src/backend/utils/misc/guc.c | 2 +- src/include/access/xlog_internal.h | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 92023de9f5..b14c7c5929 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -99,7 +99,7 @@ bool EnableHotStandby = false; bool fullPageWrites = true; bool wal_log_hints = false; bool wal_compression = false; -int wal_compression_method = WAL_COMPRESSION_ZSTD; +int wal_compression_method = WAL_COMPRESSION_ZSTD_FAST_10; char *wal_consistency_checking_string = NULL; bool *wal_consistency_checking = NULL; bool wal_init_zero = true; @@ -192,6 +192,10 @@ const struct config_enum_entry wal_compression_options[] = { #endif #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, + {"zstd-1", WAL_COMPRESSION_ZSTD_1, false}, + {"zstd-fast-10", WAL_COMPRESSION_ZSTD_FAST_10, false}, + {"zstd-fast-20", WAL_COMPRESSION_ZSTD_FAST_20, false}, + {"zstd-fast-40", WAL_COMPRESSION_ZSTD_FAST_40, false}, #endif {NULL, 0, false} }; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 5d1ae37dae..9e6bc77717 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -902,7 +902,18 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: - len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1); + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: + { + int level = compression == WAL_COMPRESSION_ZSTD_1 ? 1 : + compression == WAL_COMPRESSION_ZSTD_FAST_10 ? -10 : + compression == WAL_COMPRESSION_ZSTD_FAST_20 ? -20 : + compression == WAL_COMPRESSION_ZSTD_FAST_40 ? -40 : + ZSTD_CLEVEL_DEFAULT; + + len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, level); if (ZSTD_isError(len)) { ereport(ERROR, @@ -913,6 +924,7 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, } break; + } #endif default: diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index caa1031d63..ec795a7b9f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1569,6 +1569,10 @@ wal_compression_name(WalCompression compression) case WAL_COMPRESSION_LZ4: return "lz4"; case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: return "zstd"; default: return "???"; @@ -1629,6 +1633,10 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) #ifdef USE_ZSTD case WAL_COMPRESSION_ZSTD: + case WAL_COMPRESSION_ZSTD_1: + case WAL_COMPRESSION_ZSTD_FAST_10: + case WAL_COMPRESSION_ZSTD_FAST_20: + case WAL_COMPRESSION_ZSTD_FAST_40: decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length, ptr, bkpb->bimg_len); // XXX: ZSTD_getErrorName diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8031e027aa..667fc4c0c1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4728,7 +4728,7 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &wal_compression_method, - WAL_COMPRESSION_ZSTD, wal_compression_options, + WAL_COMPRESSION_ZSTD_FAST_10, wal_compression_options, NULL, NULL, NULL }, diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index 48b16b6083..affd6defc2 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -330,6 +330,10 @@ typedef enum WalCompression WAL_COMPRESSION_ZLIB, WAL_COMPRESSION_LZ4, WAL_COMPRESSION_ZSTD, + WAL_COMPRESSION_ZSTD_1, + WAL_COMPRESSION_ZSTD_FAST_10, /* level = -10 */ + WAL_COMPRESSION_ZSTD_FAST_20, /* level = -20 */ + WAL_COMPRESSION_ZSTD_FAST_40, /* level = -40 */ } WalCompression; extern const char *wal_compression_name(WalCompression compression); -- 2.17.0 --XsQoSWH+UP9D9v3l-- ^ permalink raw reply [nested|flat] 78+ messages in thread
* RE: Synchronizing slots from primary to standby @ 2024-04-29 05:27 Zhijie Hou (Fujitsu) <[email protected]> 2024-04-29 06:08 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> 0 siblings, 1 reply; 78+ messages in thread From: Zhijie Hou (Fujitsu) @ 2024-04-29 05:27 UTC (permalink / raw) To: Bertrand Drouvot <[email protected]>; +Cc: shveta malik <[email protected]>; Ajin Cherian <[email protected]>; Amit Kapila <[email protected]>; Peter Smith <[email protected]>; Masahiko Sawada <[email protected]>; Dilip Kumar <[email protected]>; Nisha Moond <[email protected]>; Hayato Kuroda (Fujitsu) <[email protected]>; Bharath Rupireddy <[email protected]>; Peter Eisentraut <[email protected]>; Bruce Momjian <[email protected]>; Ashutosh Sharma <[email protected]>; Andres Freund <[email protected]>; pgsql-hackers; Alvaro Herrera <[email protected]> On Friday, March 15, 2024 10:45 PM Bertrand Drouvot <[email protected]> wrote: > > Hi, > > On Thu, Mar 14, 2024 at 02:22:44AM +0000, Zhijie Hou (Fujitsu) wrote: > > Hi, > > > > Since the standby_slot_names patch has been committed, I am attaching > > the last doc patch for review. > > > > Thanks! > > 1 === > > + continue subscribing to publications now on the new primary server > without > + any data loss. > > I think "without any data loss" should be re-worded in this context. Data loss in > the sense "data committed on the primary and not visible on the subscriber in > case of failover" can still occurs (in case synchronous replication is not used). > > 2 === > > + If the result (<literal>failover_ready</literal>) of both above steps is > + true, existing subscriptions will be able to continue without data loss. > + </para> > > I don't think that's true if synchronous replication is not used. Say, > > - synchronous replication is not used > - primary is not able to reach the standby anymore and standby_slot_names is > set > - new data is inserted into the primary > - then not replicated to subscriber (due to standby_slot_names) > > Then I think the both above steps will return true but data would be lost in case > of failover. Thanks for the comments, attach the new version patch which reworded the above places. Best Regards, Hou zj Attachments: [application/octet-stream] v2-0001-Document-the-steps-to-check-if-the-standby-is-rea.patch (7.1K, ../../OS0PR01MB5716C0EE8B34170BA81BB475941B2@OS0PR01MB5716.jpnprd01.prod.outlook.com/2-v2-0001-Document-the-steps-to-check-if-the-standby-is-rea.patch) download | inline diff: From c27d69aee26752adbd1cbce531e7a5d4c7fed801 Mon Sep 17 00:00:00 2001 From: Shveta Malik <[email protected]> Date: Fri, 19 Jan 2024 11:04:16 +0530 Subject: [PATCH v2] Document the steps to check if the standby is ready for failover --- doc/src/sgml/high-availability.sgml | 9 ++ doc/src/sgml/logical-replication.sgml | 137 ++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml index b48209fc2f..ae405e029e 100644 --- a/doc/src/sgml/high-availability.sgml +++ b/doc/src/sgml/high-availability.sgml @@ -1487,6 +1487,15 @@ synchronous_standby_names = 'ANY 2 (s1, s2, s3)' Written administration procedures are advised. </para> + <para> + If you have opted for synchronization of logical slots (see + <xref linkend="logicaldecoding-replication-slots-synchronization"/>), + then before switching to the standby server, it is recommended to check + if the logical slots synchronized on the standby server are ready + for failover. This can be done by following the steps described in + <xref linkend="logical-replication-failover"/>. + </para> + <para> To trigger failover of a log-shipping standby server, run <command>pg_ctl promote</command> or call <function>pg_promote()</function>. diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index ec2130669e..fbe6dd734e 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -687,6 +687,143 @@ ALTER SUBSCRIPTION </sect1> + <sect1 id="logical-replication-failover"> + <title>Logical Replication Failover</title> + + <para> + When the publisher server is the primary server of a streaming replication, + the logical slots on that primary server can be synchronized to the standby + server by specifying <literal>failover = true</literal> when creating + subscriptions for those publications. Enabling failover ensures a seamless + transition of those subscriptions after the standby is promoted. They can + continue subscribing to publications now on the new primary server without + losing any data that has been flushed to the new primary server. + </para> + + <para> + Because the slot synchronization logic copies asynchronously, it is + necessary to confirm that replication slots have been synced to the standby + server before the failover happens. Furthermore, to ensure a successful + failover, the standby server must not be lagging behind the subscriber. It + is highly recommended to use + <link linkend="guc-standby-slot-names"><varname>standby_slot_names</varname></link> + to prevent the subscriber from consuming changes faster than the hot standby. + To confirm that the standby server is indeed ready for failover, follow + these 2 steps: + </para> + + <procedure> + <step performance="required"> + <para> + Confirm that all the necessary logical replication slots have been synced to + the standby server. + </para> + <substeps> + <step performance="required"> + <para> + Firstly, on the subscriber node, use the following SQL to identify + which slots should be synced to the standby that we plan to promote. +<programlisting> +test_sub=# SELECT + array_agg(slotname) AS slots + FROM + (( + SELECT r.srsubid AS subid, CONCAT('pg_', srsubid, '_sync_', srrelid, '_', ctl.system_identifier) AS slotname + FROM pg_control_system() ctl, pg_subscription_rel r, pg_subscription s + WHERE r.srsubstate = 'f' AND s.oid = r.srsubid AND s.subfailover + ) UNION ( + SELECT s.oid AS subid, s.subslotname as slotname + FROM pg_subscription s + WHERE s.subfailover + )); + slots +------- + {sub1,sub2,sub3} +(1 row) +</programlisting></para> + </step> + <step performance="required"> + <para> + Next, check that the logical replication slots identified above exist on + the standby server and are ready for failover. +<programlisting> +test_standby=# SELECT slot_name, (synced AND NOT temporary AND conflict_reason IS NULL) AS failover_ready + FROM pg_replication_slots + WHERE slot_name IN ('sub1','sub2','sub3'); + slot_name | failover_ready +-------------+---------------- + sub1 | t + sub2 | t + sub3 | t +(3 rows) +</programlisting></para> + </step> + </substeps> + </step> + + <step performance="required"> + <para> + Confirm that the standby server is not lagging behind the subscribers. + This step can be skipped if + <link linkend="guc-standby-slot-names"><varname>standby_slot_names</varname></link> + has been correctly configured. If standby_slot_names is not configured + correctly, it is highly recommended to run this step after the primary + server is down, otherwise the results of the query may vary at different + points of time due to the ongoing replication on the logical subscribers + from the primary server. + </para> + <substeps> + <step performance="required"> + <para> + Firstly, on the subscriber node check the last replayed WAL. + This step needs to be run on the database(s) that includes the failover + enabled subscription(s), to find the last replayed WAL on each database. +<programlisting> +test_sub=# SELECT + MAX(remote_lsn) AS remote_lsn_on_subscriber + FROM + (( + SELECT (CASE WHEN r.srsubstate = 'f' THEN pg_replication_origin_progress(CONCAT('pg_', r.srsubid, '_', r.srrelid), false) + WHEN r.srsubstate IN ('s', 'r') THEN r.srsublsn END) AS remote_lsn + FROM pg_subscription_rel r, pg_subscription s + WHERE r.srsubstate IN ('f', 's', 'r') AND s.oid = r.srsubid AND s.subfailover + ) UNION ( + SELECT pg_replication_origin_progress(CONCAT('pg_', s.oid), false) AS remote_lsn + FROM pg_subscription s + WHERE s.subfailover + )); + remote_lsn_on_subscriber +-------------------------- + 0/3000388 +</programlisting></para> + </step> + <step performance="required"> + <para> + Next, on the standby server check that the last-received WAL location + is ahead of the replayed WAL location(s) on the subscriber identified + above. If the above SQL result was NULL, it means the subscriber has not + yet replayed any WAL, so the standby server must be ahead of the + subscriber, and this step can be skipped. +<programlisting> +test_standby=# SELECT pg_last_wal_receive_lsn() >= '0/3000388'::pg_lsn AS failover_ready; + failover_ready +---------------- + t +(1 row) +</programlisting></para> + </step> + </substeps> + </step> + </procedure> + + <para> + If the result (<literal>failover_ready</literal>) of both above steps is + true, existing subscriptions will be able to continue without losing any data + that has been flushed to the new primary server. + </para> + + </sect1> + <sect1 id="logical-replication-row-filter"> <title>Row Filters</title> -- 2.30.0.windows.2 ^ permalink raw reply [nested|flat] 78+ messages in thread
* Re: Synchronizing slots from primary to standby 2024-04-29 05:27 RE: Synchronizing slots from primary to standby Zhijie Hou (Fujitsu) <[email protected]> @ 2024-04-29 06:08 ` shveta malik <[email protected]> 2024-04-29 09:08 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> 2024-04-29 09:10 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> 0 siblings, 2 replies; 78+ messages in thread From: shveta malik @ 2024-04-29 06:08 UTC (permalink / raw) To: Zhijie Hou (Fujitsu) <[email protected]>; +Cc: Bertrand Drouvot <[email protected]>; Ajin Cherian <[email protected]>; Amit Kapila <[email protected]>; Peter Smith <[email protected]>; Masahiko Sawada <[email protected]>; Dilip Kumar <[email protected]>; Nisha Moond <[email protected]>; Hayato Kuroda (Fujitsu) <[email protected]>; Bharath Rupireddy <[email protected]>; Peter Eisentraut <[email protected]>; Bruce Momjian <[email protected]>; Ashutosh Sharma <[email protected]>; Andres Freund <[email protected]>; pgsql-hackers; Alvaro Herrera <[email protected]>; shveta malik <[email protected]> On Mon, Apr 29, 2024 at 10:57 AM Zhijie Hou (Fujitsu) <[email protected]> wrote: > > On Friday, March 15, 2024 10:45 PM Bertrand Drouvot <[email protected]> wrote: > > > > Hi, > > > > On Thu, Mar 14, 2024 at 02:22:44AM +0000, Zhijie Hou (Fujitsu) wrote: > > > Hi, > > > > > > Since the standby_slot_names patch has been committed, I am attaching > > > the last doc patch for review. > > > > > > > Thanks! > > > > 1 === > > > > + continue subscribing to publications now on the new primary server > > without > > + any data loss. > > > > I think "without any data loss" should be re-worded in this context. Data loss in > > the sense "data committed on the primary and not visible on the subscriber in > > case of failover" can still occurs (in case synchronous replication is not used). > > > > 2 === > > > > + If the result (<literal>failover_ready</literal>) of both above steps is > > + true, existing subscriptions will be able to continue without data loss. > > + </para> > > > > I don't think that's true if synchronous replication is not used. Say, > > > > - synchronous replication is not used > > - primary is not able to reach the standby anymore and standby_slot_names is > > set > > - new data is inserted into the primary > > - then not replicated to subscriber (due to standby_slot_names) > > > > Then I think the both above steps will return true but data would be lost in case > > of failover. > > Thanks for the comments, attach the new version patch which reworded the > above places. Thanks for the patch. Few comments: 1) Tested the steps, one of the queries still refers to 'conflict_reason'. I think it should refer 'conflicting'. 2) Will it be good to mention that in case of planned promotion, it is recommended to run pg_sync_replication_slots() as last sync attempt before we run failvoer-ready validation steps? This can be mentioned in high-availaibility.sgml of current patch thanks Shveta ^ permalink raw reply [nested|flat] 78+ messages in thread
* Re: Synchronizing slots from primary to standby 2024-04-29 05:27 RE: Synchronizing slots from primary to standby Zhijie Hou (Fujitsu) <[email protected]> 2024-04-29 06:08 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> @ 2024-04-29 09:08 ` shveta malik <[email protected]> 1 sibling, 0 replies; 78+ messages in thread From: shveta malik @ 2024-04-29 09:08 UTC (permalink / raw) To: Zhijie Hou (Fujitsu) <[email protected]>; +Cc: Bertrand Drouvot <[email protected]>; Ajin Cherian <[email protected]>; Amit Kapila <[email protected]>; Peter Smith <[email protected]>; Masahiko Sawada <[email protected]>; Dilip Kumar <[email protected]>; Nisha Moond <[email protected]>; Hayato Kuroda (Fujitsu) <[email protected]>; Bharath Rupireddy <[email protected]>; Peter Eisentraut <[email protected]>; Bruce Momjian <[email protected]>; Ashutosh Sharma <[email protected]>; Andres Freund <[email protected]>; pgsql-hackers; Alvaro Herrera <[email protected]>; shveta malik <[email protected]>; Shveta Malik <[email protected]> On Mon, Apr 29, 2024 at 11:38 AM shveta malik <[email protected]> wrote: > > On Mon, Apr 29, 2024 at 10:57 AM Zhijie Hou (Fujitsu) > <[email protected]> wrote: > > > > On Friday, March 15, 2024 10:45 PM Bertrand Drouvot <[email protected]> wrote: > > > > > > Hi, > > > > > > On Thu, Mar 14, 2024 at 02:22:44AM +0000, Zhijie Hou (Fujitsu) wrote: > > > > Hi, > > > > > > > > Since the standby_slot_names patch has been committed, I am attaching > > > > the last doc patch for review. > > > > > > > > > > Thanks! > > > > > > 1 === > > > > > > + continue subscribing to publications now on the new primary server > > > without > > > + any data loss. > > > > > > I think "without any data loss" should be re-worded in this context. Data loss in > > > the sense "data committed on the primary and not visible on the subscriber in > > > case of failover" can still occurs (in case synchronous replication is not used). > > > > > > 2 === > > > > > > + If the result (<literal>failover_ready</literal>) of both above steps is > > > + true, existing subscriptions will be able to continue without data loss. > > > + </para> > > > > > > I don't think that's true if synchronous replication is not used. Say, > > > > > > - synchronous replication is not used > > > - primary is not able to reach the standby anymore and standby_slot_names is > > > set > > > - new data is inserted into the primary > > > - then not replicated to subscriber (due to standby_slot_names) > > > > > > Then I think the both above steps will return true but data would be lost in case > > > of failover. > > > > Thanks for the comments, attach the new version patch which reworded the > > above places. > > Thanks for the patch. > > Few comments: > > 1) Tested the steps, one of the queries still refers to > 'conflict_reason'. I think it should refer 'conflicting'. > > 2) Will it be good to mention that in case of planned promotion, it is > recommended to run pg_sync_replication_slots() as last sync attempt > before we run failvoer-ready validation steps? This can be mentioned > in high-availaibility.sgml of current patch I recall now that with the latest fix, we cannot run pg_sync_replication_slots() unless we disable the slot-sync worker. Considering that, I think it will be too many steps just to run the SQL function at the end without much value added. Thus we can skip this point, we can rely on slot sync worker completely. thanks Shveta ^ permalink raw reply [nested|flat] 78+ messages in thread
* Re: Synchronizing slots from primary to standby 2024-04-29 05:27 RE: Synchronizing slots from primary to standby Zhijie Hou (Fujitsu) <[email protected]> 2024-04-29 06:08 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> @ 2024-04-29 09:10 ` shveta malik <[email protected]> 2024-04-29 11:58 ` RE: Synchronizing slots from primary to standby Zhijie Hou (Fujitsu) <[email protected]> 1 sibling, 1 reply; 78+ messages in thread From: shveta malik @ 2024-04-29 09:10 UTC (permalink / raw) To: Zhijie Hou (Fujitsu) <[email protected]>; +Cc: Bertrand Drouvot <[email protected]>; Ajin Cherian <[email protected]>; Amit Kapila <[email protected]>; Peter Smith <[email protected]>; Masahiko Sawada <[email protected]>; Dilip Kumar <[email protected]>; Nisha Moond <[email protected]>; Hayato Kuroda (Fujitsu) <[email protected]>; Bharath Rupireddy <[email protected]>; Peter Eisentraut <[email protected]>; Bruce Momjian <[email protected]>; Ashutosh Sharma <[email protected]>; Andres Freund <[email protected]>; pgsql-hackers; Alvaro Herrera <[email protected]>; shveta malik <[email protected]> On Mon, Apr 29, 2024 at 11:38 AM shveta malik <[email protected]> wrote: > > On Mon, Apr 29, 2024 at 10:57 AM Zhijie Hou (Fujitsu) > <[email protected]> wrote: > > > > On Friday, March 15, 2024 10:45 PM Bertrand Drouvot <[email protected]> wrote: > > > > > > Hi, > > > > > > On Thu, Mar 14, 2024 at 02:22:44AM +0000, Zhijie Hou (Fujitsu) wrote: > > > > Hi, > > > > > > > > Since the standby_slot_names patch has been committed, I am attaching > > > > the last doc patch for review. > > > > > > > > > > Thanks! > > > > > > 1 === > > > > > > + continue subscribing to publications now on the new primary server > > > without > > > + any data loss. > > > > > > I think "without any data loss" should be re-worded in this context. Data loss in > > > the sense "data committed on the primary and not visible on the subscriber in > > > case of failover" can still occurs (in case synchronous replication is not used). > > > > > > 2 === > > > > > > + If the result (<literal>failover_ready</literal>) of both above steps is > > > + true, existing subscriptions will be able to continue without data loss. > > > + </para> > > > > > > I don't think that's true if synchronous replication is not used. Say, > > > > > > - synchronous replication is not used > > > - primary is not able to reach the standby anymore and standby_slot_names is > > > set > > > - new data is inserted into the primary > > > - then not replicated to subscriber (due to standby_slot_names) > > > > > > Then I think the both above steps will return true but data would be lost in case > > > of failover. > > > > Thanks for the comments, attach the new version patch which reworded the > > above places. > > Thanks for the patch. > > Few comments: > > 1) Tested the steps, one of the queries still refers to > 'conflict_reason'. I think it should refer 'conflicting'. > > 2) Will it be good to mention that in case of planned promotion, it is > recommended to run pg_sync_replication_slots() as last sync attempt > before we run failvoer-ready validation steps? This can be mentioned > in high-availaibility.sgml of current patch I recall now that with the latest fix, we cannot run pg_sync_replication_slots() unless we disable the slot-sync worker. Considering that, I think it will be too many steps just to run the SQL function at the end without much value added. Thus we can skip this point, we can rely on slot sync worker completely. thanks Shveta ^ permalink raw reply [nested|flat] 78+ messages in thread
* RE: Synchronizing slots from primary to standby 2024-04-29 05:27 RE: Synchronizing slots from primary to standby Zhijie Hou (Fujitsu) <[email protected]> 2024-04-29 06:08 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> 2024-04-29 09:10 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> @ 2024-04-29 11:58 ` Zhijie Hou (Fujitsu) <[email protected]> 2024-04-30 03:54 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> 0 siblings, 1 reply; 78+ messages in thread From: Zhijie Hou (Fujitsu) @ 2024-04-29 11:58 UTC (permalink / raw) To: shveta malik <[email protected]>; +Cc: Bertrand Drouvot <[email protected]>; Ajin Cherian <[email protected]>; Amit Kapila <[email protected]>; Peter Smith <[email protected]>; Masahiko Sawada <[email protected]>; Dilip Kumar <[email protected]>; Nisha Moond <[email protected]>; Hayato Kuroda (Fujitsu) <[email protected]>; Bharath Rupireddy <[email protected]>; Peter Eisentraut <[email protected]>; Bruce Momjian <[email protected]>; Ashutosh Sharma <[email protected]>; Andres Freund <[email protected]>; pgsql-hackers; Alvaro Herrera <[email protected]> On Monday, April 29, 2024 5:11 PM shveta malik <[email protected]> wrote: > > On Mon, Apr 29, 2024 at 11:38 AM shveta malik <[email protected]> > wrote: > > > > On Mon, Apr 29, 2024 at 10:57 AM Zhijie Hou (Fujitsu) > > <[email protected]> wrote: > > > > > > On Friday, March 15, 2024 10:45 PM Bertrand Drouvot > <[email protected]> wrote: > > > > > > > > Hi, > > > > > > > > On Thu, Mar 14, 2024 at 02:22:44AM +0000, Zhijie Hou (Fujitsu) wrote: > > > > > Hi, > > > > > > > > > > Since the standby_slot_names patch has been committed, I am > > > > > attaching the last doc patch for review. > > > > > > > > > > > > > Thanks! > > > > > > > > 1 === > > > > > > > > + continue subscribing to publications now on the new primary > > > > + server > > > > without > > > > + any data loss. > > > > > > > > I think "without any data loss" should be re-worded in this > > > > context. Data loss in the sense "data committed on the primary and > > > > not visible on the subscriber in case of failover" can still occurs (in case > synchronous replication is not used). > > > > > > > > 2 === > > > > > > > > + If the result (<literal>failover_ready</literal>) of both above steps is > > > > + true, existing subscriptions will be able to continue without data > loss. > > > > + </para> > > > > > > > > I don't think that's true if synchronous replication is not used. > > > > Say, > > > > > > > > - synchronous replication is not used > > > > - primary is not able to reach the standby anymore and > > > > standby_slot_names is set > > > > - new data is inserted into the primary > > > > - then not replicated to subscriber (due to standby_slot_names) > > > > > > > > Then I think the both above steps will return true but data would > > > > be lost in case of failover. > > > > > > Thanks for the comments, attach the new version patch which reworded > > > the above places. > > > > Thanks for the patch. > > > > Few comments: > > > > 1) Tested the steps, one of the queries still refers to > > 'conflict_reason'. I think it should refer 'conflicting'. Thanks for catching this. Fixed. > > > > 2) Will it be good to mention that in case of planned promotion, it is > > recommended to run pg_sync_replication_slots() as last sync attempt > > before we run failvoer-ready validation steps? This can be mentioned > > in high-availaibility.sgml of current patch > > I recall now that with the latest fix, we cannot run > pg_sync_replication_slots() unless we disable the slot-sync worker. > Considering that, I think it will be too many steps just to run the SQL function at > the end without much value added. Thus we can skip this point, we can rely on > slot sync worker completely. Agreed. I didn't change this. Here is the V3 doc patch. Best Regards, Hou zj Attachments: [application/octet-stream] v3-0001-Document-the-steps-to-check-if-the-standby-is-rea.patch (7.4K, ../../OS0PR01MB5716D61597A3EC8E45050AA9941B2@OS0PR01MB5716.jpnprd01.prod.outlook.com/2-v3-0001-Document-the-steps-to-check-if-the-standby-is-rea.patch) download | inline diff: From 10101239221c7d92ec6a20fd9e79d4cc09cd2299 Mon Sep 17 00:00:00 2001 From: Shveta Malik <[email protected]> Date: Fri, 19 Jan 2024 11:04:16 +0530 Subject: [PATCH v3] Document the steps to check if the standby is ready for failover This patch adds detailed documentation for the slot sync feature including examples to guide users on how to verify that all slots have been successfully synchronized to the standby server and how to confirm whether the subscription can continue subscribing to publications on the promoted standby server. --- doc/src/sgml/high-availability.sgml | 9 ++ doc/src/sgml/logical-replication.sgml | 137 ++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml index b48209fc2f..ae405e029e 100644 --- a/doc/src/sgml/high-availability.sgml +++ b/doc/src/sgml/high-availability.sgml @@ -1487,6 +1487,15 @@ synchronous_standby_names = 'ANY 2 (s1, s2, s3)' Written administration procedures are advised. </para> + <para> + If you have opted for synchronization of logical slots (see + <xref linkend="logicaldecoding-replication-slots-synchronization"/>), + then before switching to the standby server, it is recommended to check + if the logical slots synchronized on the standby server are ready + for failover. This can be done by following the steps described in + <xref linkend="logical-replication-failover"/>. + </para> + <para> To trigger failover of a log-shipping standby server, run <command>pg_ctl promote</command> or call <function>pg_promote()</function>. diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index ec2130669e..947bd652ea 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -687,6 +687,143 @@ ALTER SUBSCRIPTION </sect1> + <sect1 id="logical-replication-failover"> + <title>Logical Replication Failover</title> + + <para> + When the publisher server is the primary server of a streaming replication, + the logical slots on that primary server can be synchronized to the standby + server by specifying <literal>failover = true</literal> when creating + subscriptions for those publications. Enabling failover ensures a seamless + transition of those subscriptions after the standby is promoted. They can + continue subscribing to publications now on the new primary server without + losing any data that has been flushed to the new primary server. + </para> + + <para> + Because the slot synchronization logic copies asynchronously, it is + necessary to confirm that replication slots have been synced to the standby + server before the failover happens. Furthermore, to ensure a successful + failover, the standby server must not be lagging behind the subscriber. It + is highly recommended to use + <link linkend="guc-standby-slot-names"><varname>standby_slot_names</varname></link> + to prevent the subscriber from consuming changes faster than the hot standby. + To confirm that the standby server is indeed ready for failover, follow + these 2 steps: + </para> + + <procedure> + <step performance="required"> + <para> + Confirm that all the necessary logical replication slots have been synced to + the standby server. + </para> + <substeps> + <step performance="required"> + <para> + Firstly, on the subscriber node, use the following SQL to identify + which slots should be synced to the standby that we plan to promote. +<programlisting> +test_sub=# SELECT + array_agg(slotname) AS slots + FROM + (( + SELECT r.srsubid AS subid, CONCAT('pg_', srsubid, '_sync_', srrelid, '_', ctl.system_identifier) AS slotname + FROM pg_control_system() ctl, pg_subscription_rel r, pg_subscription s + WHERE r.srsubstate = 'f' AND s.oid = r.srsubid AND s.subfailover + ) UNION ( + SELECT s.oid AS subid, s.subslotname as slotname + FROM pg_subscription s + WHERE s.subfailover + )); + slots +------- + {sub1,sub2,sub3} +(1 row) +</programlisting></para> + </step> + <step performance="required"> + <para> + Next, check that the logical replication slots identified above exist on + the standby server and are ready for failover. +<programlisting> +test_standby=# SELECT slot_name, (synced AND NOT temporary AND NOT conflicting) AS failover_ready + FROM pg_replication_slots + WHERE slot_name IN ('sub1','sub2','sub3'); + slot_name | failover_ready +-------------+---------------- + sub1 | t + sub2 | t + sub3 | t +(3 rows) +</programlisting></para> + </step> + </substeps> + </step> + + <step performance="required"> + <para> + Confirm that the standby server is not lagging behind the subscribers. + This step can be skipped if + <link linkend="guc-standby-slot-names"><varname>standby_slot_names</varname></link> + has been correctly configured. If standby_slot_names is not configured + correctly, it is highly recommended to run this step after the primary + server is down, otherwise the results of the query may vary at different + points of time due to the ongoing replication on the logical subscribers + from the primary server. + </para> + <substeps> + <step performance="required"> + <para> + Firstly, on the subscriber node check the last replayed WAL. + This step needs to be run on the database(s) that includes the failover + enabled subscription(s), to find the last replayed WAL on each database. +<programlisting> +test_sub=# SELECT + MAX(remote_lsn) AS remote_lsn_on_subscriber + FROM + (( + SELECT (CASE WHEN r.srsubstate = 'f' THEN pg_replication_origin_progress(CONCAT('pg_', r.srsubid, '_', r.srrelid), false) + WHEN r.srsubstate IN ('s', 'r') THEN r.srsublsn END) AS remote_lsn + FROM pg_subscription_rel r, pg_subscription s + WHERE r.srsubstate IN ('f', 's', 'r') AND s.oid = r.srsubid AND s.subfailover + ) UNION ( + SELECT pg_replication_origin_progress(CONCAT('pg_', s.oid), false) AS remote_lsn + FROM pg_subscription s + WHERE s.subfailover + )); + remote_lsn_on_subscriber +-------------------------- + 0/3000388 +</programlisting></para> + </step> + <step performance="required"> + <para> + Next, on the standby server check that the last-received WAL location + is ahead of the replayed WAL location(s) on the subscriber identified + above. If the above SQL result was NULL, it means the subscriber has not + yet replayed any WAL, so the standby server must be ahead of the + subscriber, and this step can be skipped. +<programlisting> +test_standby=# SELECT pg_last_wal_receive_lsn() >= '0/3000388'::pg_lsn AS failover_ready; + failover_ready +---------------- + t +(1 row) +</programlisting></para> + </step> + </substeps> + </step> + </procedure> + + <para> + If the result (<literal>failover_ready</literal>) of both above steps is + true, existing subscriptions will be able to continue without losing any data + that has been flushed to the new primary server. + </para> + + </sect1> + <sect1 id="logical-replication-row-filter"> <title>Row Filters</title> -- 2.30.0.windows.2 ^ permalink raw reply [nested|flat] 78+ messages in thread
* Re: Synchronizing slots from primary to standby 2024-04-29 05:27 RE: Synchronizing slots from primary to standby Zhijie Hou (Fujitsu) <[email protected]> 2024-04-29 06:08 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> 2024-04-29 09:10 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> 2024-04-29 11:58 ` RE: Synchronizing slots from primary to standby Zhijie Hou (Fujitsu) <[email protected]> @ 2024-04-30 03:54 ` shveta malik <[email protected]> 0 siblings, 0 replies; 78+ messages in thread From: shveta malik @ 2024-04-30 03:54 UTC (permalink / raw) To: Zhijie Hou (Fujitsu) <[email protected]>; +Cc: Bertrand Drouvot <[email protected]>; Ajin Cherian <[email protected]>; Amit Kapila <[email protected]>; Peter Smith <[email protected]>; Masahiko Sawada <[email protected]>; Dilip Kumar <[email protected]>; Nisha Moond <[email protected]>; Hayato Kuroda (Fujitsu) <[email protected]>; Bharath Rupireddy <[email protected]>; Peter Eisentraut <[email protected]>; Bruce Momjian <[email protected]>; Ashutosh Sharma <[email protected]>; Andres Freund <[email protected]>; pgsql-hackers; Alvaro Herrera <[email protected]>; shveta malik <[email protected]> On Mon, Apr 29, 2024 at 5:28 PM Zhijie Hou (Fujitsu) <[email protected]> wrote: > > On Monday, April 29, 2024 5:11 PM shveta malik <[email protected]> wrote: > > > > On Mon, Apr 29, 2024 at 11:38 AM shveta malik <[email protected]> > > wrote: > > > > > > On Mon, Apr 29, 2024 at 10:57 AM Zhijie Hou (Fujitsu) > > > <[email protected]> wrote: > > > > > > > > On Friday, March 15, 2024 10:45 PM Bertrand Drouvot > > <[email protected]> wrote: > > > > > > > > > > Hi, > > > > > > > > > > On Thu, Mar 14, 2024 at 02:22:44AM +0000, Zhijie Hou (Fujitsu) wrote: > > > > > > Hi, > > > > > > > > > > > > Since the standby_slot_names patch has been committed, I am > > > > > > attaching the last doc patch for review. > > > > > > > > > > > > > > > > Thanks! > > > > > > > > > > 1 === > > > > > > > > > > + continue subscribing to publications now on the new primary > > > > > + server > > > > > without > > > > > + any data loss. > > > > > > > > > > I think "without any data loss" should be re-worded in this > > > > > context. Data loss in the sense "data committed on the primary and > > > > > not visible on the subscriber in case of failover" can still occurs (in case > > synchronous replication is not used). > > > > > > > > > > 2 === > > > > > > > > > > + If the result (<literal>failover_ready</literal>) of both above steps is > > > > > + true, existing subscriptions will be able to continue without data > > loss. > > > > > + </para> > > > > > > > > > > I don't think that's true if synchronous replication is not used. > > > > > Say, > > > > > > > > > > - synchronous replication is not used > > > > > - primary is not able to reach the standby anymore and > > > > > standby_slot_names is set > > > > > - new data is inserted into the primary > > > > > - then not replicated to subscriber (due to standby_slot_names) > > > > > > > > > > Then I think the both above steps will return true but data would > > > > > be lost in case of failover. > > > > > > > > Thanks for the comments, attach the new version patch which reworded > > > > the above places. > > > > > > Thanks for the patch. > > > > > > Few comments: > > > > > > 1) Tested the steps, one of the queries still refers to > > > 'conflict_reason'. I think it should refer 'conflicting'. > > Thanks for catching this. Fixed. > > > > > > > 2) Will it be good to mention that in case of planned promotion, it is > > > recommended to run pg_sync_replication_slots() as last sync attempt > > > before we run failvoer-ready validation steps? This can be mentioned > > > in high-availaibility.sgml of current patch > > > > I recall now that with the latest fix, we cannot run > > pg_sync_replication_slots() unless we disable the slot-sync worker. > > Considering that, I think it will be too many steps just to run the SQL function at > > the end without much value added. Thus we can skip this point, we can rely on > > slot sync worker completely. > > Agreed. I didn't change this. > > Here is the V3 doc patch. Thanks for the patch. It will be good if 1a can produce quoted slot-names list as output, which can be used directly in step 1b's query; otherwise, it is little inconvenient to give input to 1b if the number of slots are huge. User needs to manually quote each slot-name. Other than this, the patch looks good to me. thanks Shveta ^ permalink raw reply [nested|flat] 78+ messages in thread
end of thread, other threads:[~2024-04-30 03:54 UTC | newest] Thread overview: 78+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2021-03-14 22:12 [PATCH 09/10] Add zstd compression levels Justin Pryzby <[email protected]> 2024-04-29 05:27 RE: Synchronizing slots from primary to standby Zhijie Hou (Fujitsu) <[email protected]> 2024-04-29 06:08 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> 2024-04-29 09:08 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> 2024-04-29 09:10 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]> 2024-04-29 11:58 ` RE: Synchronizing slots from primary to standby Zhijie Hou (Fujitsu) <[email protected]> 2024-04-30 03:54 ` Re: Synchronizing slots from primary to standby shveta malik <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox