]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
change to >= convergence counter
authorPaul Cruz <paulcruz74@fb.com>
Wed, 26 Jul 2017 17:20:29 +0000 (10:20 -0700)
committerPaul Cruz <paulcruz74@fb.com>
Wed, 26 Jul 2017 17:20:29 +0000 (10:20 -0700)
contrib/adaptive-compression/adapt.c

index 1633b6bf8db84ba18b8ad2e8875d24a630653fea..d75660806e20fe8e8be1daf58b5c3acd35d0beeb 100644 (file)
@@ -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) {