]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
build macro ZSTD_DECODER_INTERNAL_BUFFER
authorYann Collet <cyan@fb.com>
Mon, 25 Oct 2021 15:09:04 +0000 (08:09 -0700)
committerYann Collet <cyan@fb.com>
Mon, 25 Oct 2021 15:09:04 +0000 (08:09 -0700)
just to make the topic more accessible for potential users.

lib/README.md
lib/decompress/zstd_decompress_internal.h

index 9cbeb8d4f3d65690bd07dbec92338c84f96a2a39..aab0869af00c2824473fb4dccb1a61f06c94e4f1 100644 (file)
@@ -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
index ac5586cc702654228d294686d09ab8615455a79a..7f555911d6ee7ad55638b881902b2a367fd2856e 100644 (file)
@@ -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) */