added definitions for conversion constants, moved forced compression check to top of adaptCompressionLevel, used ZSTD_BLOCKSIZE_MAX

dev
Paul Cruz 2017-07-26 15:52:15 -07:00
parent 6c1c1242fc
commit 715f36ca81
1 changed files with 12 additions and 7 deletions

View File

@ -28,6 +28,8 @@
#define MAX_COMPRESSION_LEVEL_CHANGE 2
#define CONVERGENCE_LOWER_BOUND 5
#define CLEVEL_DECREASE_COOLDOWN 5
#define CHANGE_BY_TWO_THRESHOLD 0.1
#define CHANGE_BY_ONE_THRESHOLD 0.65
#ifndef DEBUG_MODE
static int g_displayLevel = DEFAULT_DISPLAY_LEVEL;
@ -322,10 +324,10 @@ static void waitUntilAllJobsCompleted(adaptCCtx* ctx)
/* map completion percentages to values for changing compression level */
static unsigned convertCompletionToChange(double completion)
{
if (completion < 0.1) {
if (completion < CHANGE_BY_TWO_THRESHOLD) {
return 2;
}
else if (completion < 0.65) {
else if (completion < CHANGE_BY_ONE_THRESHOLD) {
return 1;
}
else {
@ -350,6 +352,13 @@ static void adaptCompressionLevel(adaptCCtx* ctx)
double const threshold = 0.00001;
unsigned const prevCompressionLevel = ctx->compressionLevel;
if (g_forceCompressionLevel) {
ctx->compressionLevel = g_compressionLevel;
return;
}
DEBUG(2, "adapting compression level %u\n", ctx->compressionLevel);
/* read and reset completion measurements */
@ -420,10 +429,6 @@ static void adaptCompressionLevel(adaptCCtx* ctx)
if (ctx->compressionLevel == prevCompressionLevel) {
ctx->convergenceCounter++;
}
if (g_forceCompressionLevel) {
ctx->compressionLevel = g_compressionLevel;
}
}
static size_t getUseableDictSize(unsigned compressionLevel)
@ -500,7 +505,7 @@ static void* compressionThread(void* arg)
DEBUG(2, "job %u compressed with level %u\n", currJob, ctx->compressionLevel);
/* compress the data */
{
size_t const compressionBlockSize = 1 << 17; /* 128 KB */
size_t const compressionBlockSize = ZSTD_BLOCKSIZE_MAX; /* 128 KB */
unsigned const cLevel = ctx->compressionLevel;
unsigned blockNum = 0;
size_t remaining = job->src.size;