@@ -244,7 +244,9 @@ static void usageAdvanced(const char* programName)
244244 DISPLAYOUT (" --stream-size=# Specify size of streaming input from STDIN.\n" );
245245 DISPLAYOUT (" --size-hint=# Optimize compression parameters for streaming input of approximately size #.\n" );
246246 DISPLAYOUT (" --target-compressed-block-size=#\n" );
247- DISPLAYOUT (" Generate compressed blocks of approximately # size.\n\n" );
247+ DISPLAYOUT (" Generate compressed blocks of approximately # size.\n" );
248+ DISPLAYOUT (" --constrain-window={none,http-zstd,http-dcz}\n" );
249+ DISPLAYOUT (" Constrain window size to comply with limits set by protocol. [Default: none]\n\n" );
248250 DISPLAYOUT (" --no-dictID Don't write `dictID` into the header (dictionary compression only).\n" );
249251 DISPLAYOUT (" --[no-]compress-literals Force (un)compressed literals.\n" );
250252 DISPLAYOUT (" --[no-]row-match-finder Explicitly enable/disable the fast, row-based matchfinder for\n" );
@@ -851,6 +853,7 @@ int main(int argCount, const char* argv[])
851853 removeSrcFile = 0 ;
852854 ZSTD_ParamSwitch_e mmapDict = ZSTD_ps_auto ;
853855 ZSTD_ParamSwitch_e useRowMatchFinder = ZSTD_ps_auto ;
856+ ZSTD_ConstrainWindow_e constrainWindowForProtocol = ZSTD_ConstrainWindow_auto ;
854857 FIO_compressionType_t cType = FIO_zstdCompression ;
855858 int nbWorkers = -1 ; /* -1 means unset */
856859 double compressibility = -1.0 ; /* lorem ipsum generator */
@@ -1135,6 +1138,23 @@ int main(int argCount, const char* argv[])
11351138 continue ;
11361139 }
11371140
1141+
1142+ if (longCommandWArg (& argument , "--constrain-window" )) {
1143+ const char * protocol ;
1144+ NEXT_FIELD (protocol );
1145+ if (!strncmp (protocol , "none" , strlen ("none" ) + 1 )) {
1146+ constrainWindowForProtocol = ZSTD_ConstrainWindow_HTTP_Zstd ;
1147+ } else if (!strncmp (protocol , "http-zstd" , strlen ("http-zstd" ) + 1 )) {
1148+ constrainWindowForProtocol = ZSTD_ConstrainWindow_HTTP_Zstd ;
1149+ } else if (!strncmp (protocol , "http-dcz" , strlen ("http-dcz" ) + 1 )) {
1150+ constrainWindowForProtocol = ZSTD_ConstrainWindow_HTTP_DCZ ;
1151+ } else {
1152+ badUsage (programName , originalArgument );
1153+ CLEAN_RETURN (1 );
1154+ }
1155+ continue ;
1156+ }
1157+
11381158 badUsage (programName , originalArgument );
11391159 CLEAN_RETURN (1 );
11401160 }
@@ -1573,6 +1593,7 @@ int main(int argCount, const char* argv[])
15731593 FIO_setSrcSizeHint (prefs , srcSizeHint );
15741594 FIO_setLiteralCompressionMode (prefs , literalCompressionMode );
15751595 FIO_setSparseWrite (prefs , 0 );
1596+ FIO_setConstrainWindowForProtocol (prefs , constrainWindowForProtocol );
15761597 if (adaptMin > cLevel ) cLevel = adaptMin ;
15771598 if (adaptMax < cLevel ) cLevel = adaptMax ;
15781599
@@ -1603,6 +1624,7 @@ int main(int argCount, const char* argv[])
16031624 (void )ultra ; (void )cLevel ; (void )ldmFlag ; (void )literalCompressionMode ;
16041625 (void )targetCBlockSize ; (void )streamSrcSize ; (void )srcSizeHint ;
16051626 (void )ZSTD_strategyMap ; (void )useRowMatchFinder ; (void )cType ;
1627+ (void )constrainWindowForProtocol ;
16061628 DISPLAYLEVEL (1 , "Compression not supported \n" );
16071629#endif
16081630 } else { /* decompression or test */
0 commit comments