Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion programs/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ FIO_prefs_t* FIO_createPreferences(void)
ret->allowBlockDevices = 0;
ret->asyncIO = AIO_supported();
ret->passThrough = -1;
ret->inputBufferSize = 0; /* 0 = use default */
return ret;
}

Expand Down Expand Up @@ -682,6 +683,10 @@ void FIO_setSrcSizeHint(FIO_prefs_t* const prefs, size_t srcSizeHint) {
prefs->srcSizeHint = (int)MIN((size_t)INT_MAX, srcSizeHint);
}

void FIO_setInputBufferSize(FIO_prefs_t* const prefs, size_t inputBufferSize) {
prefs->inputBufferSize = inputBufferSize;
}

void FIO_setTestMode(FIO_prefs_t* const prefs, int testMode) {
prefs->testMode = (testMode!=0);
}
Expand Down Expand Up @@ -2611,7 +2616,8 @@ static dRess_t FIO_createDResources(FIO_prefs_t* const prefs, const char* dictFi
}

ress.writeCtx = AIO_WritePool_create(prefs, ZSTD_DStreamOutSize());
ress.readCtx = AIO_ReadPool_create(prefs, ZSTD_DStreamInSize());
ress.readCtx = AIO_ReadPool_create(prefs,
prefs->inputBufferSize > 0 ? prefs->inputBufferSize : ZSTD_DStreamInSize());
return ress;
}

Expand Down
1 change: 1 addition & 0 deletions programs/fileio.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void FIO_setRsyncable(FIO_prefs_t* const prefs, int rsyncable);
void FIO_setStreamSrcSize(FIO_prefs_t* const prefs, size_t streamSrcSize);
void FIO_setTargetCBlockSize(FIO_prefs_t* const prefs, size_t targetCBlockSize);
void FIO_setSrcSizeHint(FIO_prefs_t* const prefs, size_t srcSizeHint);
void FIO_setInputBufferSize(FIO_prefs_t* const prefs, size_t inputBufferSize);
void FIO_setTestMode(FIO_prefs_t* const prefs, int testMode);
void FIO_setLiteralCompressionMode(
FIO_prefs_t* const prefs,
Expand Down
1 change: 1 addition & 0 deletions programs/fileio_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ typedef struct FIO_prefs_s {
int removeSrcFile;
int overwrite;
int asyncIO;
size_t inputBufferSize; /* size of the input buffer for decompression (0 = default) */

/* Computation resources preferences */
unsigned memLimit;
Expand Down
4 changes: 4 additions & 0 deletions programs/zstdcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ static void usageAdvanced(const char* programName)
DISPLAYOUT(" --exclude-compressed Only compress files that are not already compressed.\n\n");

DISPLAYOUT(" --stream-size=# Specify size of streaming input from STDIN.\n");
DISPLAYOUT(" --ibuf-size=# Specify input buffer size for decompression. Helps with large files on slow disks.\n");
DISPLAYOUT(" --size-hint=# Optimize compression parameters for streaming input of approximately size #.\n");
DISPLAYOUT(" --target-compressed-block-size=#\n");
DISPLAYOUT(" Generate compressed blocks of approximately # size.\n\n");
Expand Down Expand Up @@ -912,6 +913,7 @@ int main(int argCount, const char* argv[])
size_t streamSrcSize = 0;
size_t targetCBlockSize = 0;
size_t srcSizeHint = 0;
size_t inputBufferSize = 0;
size_t nbInputFileNames = 0;
int dictCLevel = g_defaultDictCLevel;
unsigned dictSelect = g_defaultSelectivityLevel;
Expand Down Expand Up @@ -1096,6 +1098,7 @@ int main(int argCount, const char* argv[])
if (longCommandWArg(&argument, "--dictID")) { NEXT_UINT32(dictID); continue; }
if (longCommandWArg(&argument, "--zstd=")) { if (!parseCompressionParameters(argument, &compressionParams)) { badUsage(programName, originalArgument); CLEAN_RETURN(1); } ; cType = FIO_zstdCompression; continue; }
if (longCommandWArg(&argument, "--stream-size")) { NEXT_TSIZE(streamSrcSize); continue; }
if (longCommandWArg(&argument, "--ibuf-size")) { NEXT_TSIZE(inputBufferSize); continue; }
if (longCommandWArg(&argument, "--target-compressed-block-size")) { NEXT_TSIZE(targetCBlockSize); continue; }
if (longCommandWArg(&argument, "--size-hint")) { NEXT_TSIZE(srcSizeHint); continue; }
if (longCommandWArg(&argument, "--output-dir-flat")) {
Expand Down Expand Up @@ -1615,6 +1618,7 @@ int main(int argCount, const char* argv[])
FIO_setStreamSrcSize(prefs, streamSrcSize);
FIO_setTargetCBlockSize(prefs, targetCBlockSize);
FIO_setSrcSizeHint(prefs, srcSizeHint);
FIO_setInputBufferSize(prefs, inputBufferSize);
FIO_setLiteralCompressionMode(prefs, literalCompressionMode);
FIO_setSparseWrite(prefs, 0);
if (adaptMin > cLevel) cLevel = adaptMin;
Expand Down