From: Yann Collet Date: Mon, 25 Oct 2021 15:09:04 +0000 (-0700) Subject: build macro ZSTD_DECODER_INTERNAL_BUFFER X-Git-Tag: v1.5.1~1^2~70^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02be2a830f20e5801386be87d7f816776a068516;p=thirdparty%2Fzstd.git build macro ZSTD_DECODER_INTERNAL_BUFFER just to make the topic more accessible for potential users. --- diff --git a/lib/README.md b/lib/README.md index 9cbeb8d4f..aab0869af 100644 --- a/lib/README.md +++ b/lib/README.md @@ -155,11 +155,11 @@ The file structure is designed to make this selection manually achievable for an - The build macro `ZSTD_NO_INTRINSICS` can be defined to disable all explicit intrinsics. Compiler builtins are still used. -- The build macro `ZSTD_LITBUFFEREXTRASIZE` can be set to control the amount of extra memory used - during decompression to store literals. This defaults to 64kB. Reducing it can reduce the - memory footprint required for decompression by increasing the portion of the literal buffer that - is stored in the unwritten portion of the dst buffer, at the cost of performance impact for - decompression. +- The build macro `ZSTD_DECODER_INTERNAL_BUFFER` can be set to control + the amount of extra memory used during decompression to store literals. + This defaults to 64kB. Reducing this value reduces the memory footprint of + `ZSTD_DCtx` decompression contexts, + but might also result in a small decompression speed cost. #### Windows : using MinGW+MSYS to create DLL diff --git a/lib/decompress/zstd_decompress_internal.h b/lib/decompress/zstd_decompress_internal.h index ac5586cc7..7f555911d 100644 --- a/lib/decompress/zstd_decompress_internal.h +++ b/lib/decompress/zstd_decompress_internal.h @@ -106,10 +106,15 @@ typedef struct { size_t ddictPtrCount; } ZSTD_DDictHashSet; -#ifndef ZSTD_LITBUFFEREXTRASIZE -#define ZSTD_LITBUFFEREXTRASIZE (1 << 16) /* extra buffer reduces amount of dst required to store litBuffer */ +#ifndef ZSTD_DECODER_INTERNAL_BUFFER +# define ZSTD_DECODER_INTERNAL_BUFFER (1 << 16) #endif +#define ZSTD_LBMAX (128 << 10) + +/* extra buffer, compensates amount of dst required to store litBuffer */ +#define ZSTD_LITBUFFEREXTRASIZE MIN(ZSTD_DECODER_INTERNAL_BUFFER, ZSTD_LBMAX) + typedef enum { ZSTD_not_in_dst = 0, /* Stored entirely within litExtraBuffer */ ZSTD_in_dst = 1, /* Stored entirely within dst (in memory after current output write) */