]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
added command --block-size=
authorYann Collet <cyan@fb.com>
Mon, 30 Jan 2017 19:17:26 +0000 (11:17 -0800)
committerYann Collet <cyan@fb.com>
Mon, 30 Jan 2017 19:17:26 +0000 (11:17 -0800)
for Multi-threading only.
alias : -B#

programs/fileio.c
programs/fileio.h
programs/zstdcli.c

index 353fbd54e1e1e22e377ca9caed4c7cd514f58b06..abaa15e535695cfaa24d70f40198e83d4cd5a8b8 100644 (file)
@@ -124,6 +124,13 @@ void FIO_setBlockSize(unsigned blockSize) {
 #endif
     g_blockSize = blockSize;
 }
+static const U32 g_overlapLogNotSet = 9999;
+static U32 g_overlapLog = g_overlapLogNotSet;
+void FIO_setOverlapLog(unsigned overlapLog){
+    if (overlapLog && g_nbThreads==1)
+        DISPLAYLEVEL(2, "Setting overlapLog is useless in single-thread mode \n");
+    g_overlapLog = overlapLog;
+}
 
 
 /*-*************************************
@@ -272,8 +279,10 @@ static cRess_t FIO_createCResources(const char* dictFileName, int cLevel,
 #ifdef ZSTD_MULTITHREAD
     ress.cctx = ZSTDMT_createCCtx(g_nbThreads);
     if (ress.cctx == NULL) EXM_THROW(30, "zstd: allocation error : can't create ZSTD_CStream");
-    if (cLevel==ZSTD_maxCLevel())
-        ZSTDMT_setMTCtxParameter(ress.cctx, ZSTDMT_p_overlapSectionRLog, 0);   /* use complete window for overlap */
+    if ((cLevel==ZSTD_maxCLevel()) && (g_overlapLog==g_overlapLogNotSet))
+        ZSTDMT_setMTCtxParameter(ress.cctx, ZSTDMT_p_overlapSectionLog, 0);   /* use complete window for overlap */
+    if (g_overlapLog != g_overlapLogNotSet)
+        ZSTDMT_setMTCtxParameter(ress.cctx, ZSTDMT_p_overlapSectionLog, g_overlapLog);
 #else
     ress.cctx = ZSTD_createCStream();
     if (ress.cctx == NULL) EXM_THROW(30, "zstd: allocation error : can't create ZSTD_CStream");
@@ -355,7 +364,6 @@ static int FIO_compressFilename_internal(cRess_t ress,
         size_t const inSize = fread(ress.srcBuffer, (size_t)1, ress.srcBufferSize, srcFile);
         if (inSize==0) break;
         readsize += inSize;
-        DISPLAYUPDATE(2, "\rRead : %u MB  ", (U32)(readsize>>20));
 
         {   ZSTD_inBuffer  inBuff = { ress.srcBuffer, inSize, 0 };
             while (inBuff.pos != inBuff.size) {   /* note : is there any possibility of endless loop ? for example, if outBuff is not large enough ? */
index 11178bcca94f862f36f42f127170c9bc8e9760ff..daff0312e101dec87574a6a828ba22df3580167b 100644 (file)
@@ -43,6 +43,7 @@ void FIO_setRemoveSrcFile(unsigned flag);
 void FIO_setMemLimit(unsigned memLimit);
 void FIO_setNbThreads(unsigned nbThreads);
 void FIO_setBlockSize(unsigned blockSize);
+void FIO_setOverlapLog(unsigned overlapLog);
 
 
 /*-*************************************
index 64f2c919c80a00024147d3ebb9626384417ae90e..c6c8cd2bdfc82739cd929175b675665a006f6666 100644 (file)
@@ -370,6 +370,7 @@ int main(int argCount, const char* argv[])
                     if (longCommandWArg(&argument, "--memlimit=")) { memLimit = readU32FromChar(&argument); continue; }
                     if (longCommandWArg(&argument, "--memory=")) { memLimit = readU32FromChar(&argument); continue; }
                     if (longCommandWArg(&argument, "--memlimit-decompress=")) { memLimit = readU32FromChar(&argument); continue; }
+                    if (longCommandWArg(&argument, "--block-size=")) { blockSize = readU32FromChar(&argument); continue; }
                     if (longCommandWArg(&argument, "--zstd=")) { if (!parseCompressionParameters(argument, &compressionParams)) CLEAN_RETURN(badusage(programName)); continue; }
                     /* fall-through, will trigger bad_usage() later on */
                 }