From: Paul Cruz Date: Wed, 26 Jul 2017 17:20:29 +0000 (-0700) Subject: change to >= convergence counter X-Git-Tag: v1.3.1^2~13^2^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=305d5ee70f41cb89f2d373abf703b09dfedcda61;p=thirdparty%2Fzstd.git change to >= convergence counter --- diff --git a/contrib/adaptive-compression/adapt.c b/contrib/adaptive-compression/adapt.c index 1633b6bf8..d75660806 100644 --- a/contrib/adaptive-compression/adapt.c +++ b/contrib/adaptive-compression/adapt.c @@ -384,33 +384,37 @@ static void adaptCompressionLevel(adaptCCtx* ctx) double const completion = MAX(createWaitCompressionCompletion, writeWaitCompressionCompletion); unsigned const change = convertCompletionToChange(completion); unsigned const boundChange = MIN(change, ctx->compressionLevel - 1); - if (ctx->convergenceCounter > CONVERGENCE_LOWER_BOUND && boundChange != 0) { + if (ctx->convergenceCounter >= CONVERGENCE_LOWER_BOUND && boundChange != 0) { /* reset convergence counter, might have been a spike */ ctx->convergenceCounter = 0; + DEBUG(2, "convergence counter reset, no change applied\n"); } else if (boundChange != 0) { ctx->compressionLevel -= boundChange; ctx->cooldown = CLEVEL_DECREASE_COOLDOWN; ctx->convergenceCounter = 1; - } - DEBUG(2, "create or write threads waiting on compression, tried to decrease compression level by %u\n\n", boundChange); + DEBUG(2, "create or write threads waiting on compression, tried to decrease compression level by %u\n\n", boundChange); + } } else if (1-compressWaitWriteCompletion > threshold || 1-compressWaitCreateCompletion > threshold) { /* compress waiting on write */ double const completion = MIN(compressWaitWriteCompletion, compressWaitCreateCompletion); unsigned const change = convertCompletionToChange(completion); unsigned const boundChange = MIN(change, ZSTD_maxCLevel() - ctx->compressionLevel); - if (ctx->convergenceCounter > CONVERGENCE_LOWER_BOUND && boundChange != 0) { + if (ctx->convergenceCounter >= CONVERGENCE_LOWER_BOUND && boundChange != 0) { + /* reset convergence counter, might have been a spike */ ctx->convergenceCounter = 0; + DEBUG(2, "convergence counter reset, no change applied\n"); } else if (boundChange != 0) { ctx->compressionLevel += boundChange; ctx->cooldown = 0; ctx->convergenceCounter = 1; + + DEBUG(2, "compress waiting on write or create, tried to increase compression level by %u\n\n", boundChange); } - DEBUG(2, "compress waiting on write or create, tried to increase compression level by %u\n\n", boundChange); } if (ctx->compressionLevel == prevCompressionLevel) {