]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
reduced pool queue to 0 to save memory 807/head
authorYann Collet <cyan@fb.com>
Sat, 19 Aug 2017 22:07:54 +0000 (15:07 -0700)
committerYann Collet <cyan@fb.com>
Sat, 19 Aug 2017 22:07:54 +0000 (15:07 -0700)
fixed : pool performance when jobs are fires fast and queueSize==0

lib/common/pool.c
lib/compress/zstdmt_compress.c
lib/legacy/zstd_legacy.h

index bcea21ca0269570aed09ecc79bcddf66726571fb..a227044f7f1ce302895d990e4d3e900a49b91273 100644 (file)
@@ -76,17 +76,13 @@ static void* POOL_thread(void* opaque) {
             return opaque;
         }
         /* Pop a job off the queue */
-        {
-            POOL_job const job = ctx->queue[ctx->queueHead];
+        {   POOL_job const job = ctx->queue[ctx->queueHead];
             ctx->queueHead = (ctx->queueHead + 1) % ctx->queueSize;
             ctx->numThreadsBusy++;
             ctx->queueEmpty = ctx->queueHead == ctx->queueTail;
             /* Unlock the mutex, signal a pusher, and run the job */
             pthread_mutex_unlock(&ctx->queueMutex);
-
-            if (ctx->queueSize > 1) {
-                pthread_cond_signal(&ctx->queuePushCond);
-            }
+            pthread_cond_signal(&ctx->queuePushCond);
 
             job.function(job.opaque);
 
@@ -96,9 +92,8 @@ static void* POOL_thread(void* opaque) {
                 ctx->numThreadsBusy--;
                 pthread_mutex_unlock(&ctx->queueMutex);
                 pthread_cond_signal(&ctx->queuePushCond);
-            }
-        }
-    }
+        }   }
+    }  /* for (;;) */
     /* Unreachable */
 }
 
index 02bb7c593fc93cf5e284f908e642b3c88de54938..8564bc439214df313b80684735aedf3d17022710 100644 (file)
@@ -426,7 +426,7 @@ ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbThreads, ZSTD_customMem cMem)
     mtctx->allJobsCompleted = 1;
     mtctx->sectionSize = 0;
     mtctx->overlapLog = ZSTDMT_OVERLAPLOG_DEFAULT;
-    mtctx->factory = POOL_create(nbThreads, 1);
+    mtctx->factory = POOL_create(nbThreads, 0);
     mtctx->jobs = ZSTDMT_allocJobsTable(&nbJobs, cMem);
     mtctx->jobIDMask = nbJobs - 1;
     mtctx->bufPool = ZSTDMT_createBufferPool(nbThreads, cMem);
index 6342192eec973b57d82f489d50bf068289b899be..1126e24669f33e362a26e15aa126c1bb19064698 100644 (file)
@@ -123,6 +123,7 @@ MEM_STATIC size_t ZSTD_decompressLegacy(
                const void* dict,size_t dictSize)
 {
     U32 const version = ZSTD_isLegacy(src, compressedSize);
+    (void)dst; (void)dstCapacity; (void)dict; (void)dictSize;  /* unused when ZSTD_LEGACY_SUPPORT >= 8 */
     switch(version)
     {
 #if (ZSTD_LEGACY_SUPPORT <= 1)
@@ -223,6 +224,7 @@ MEM_STATIC size_t ZSTD_freeLegacyStreamContext(void* legacyContext, U32 version)
         case 1 :
         case 2 :
         case 3 :
+            (void)legacyContext;
             return ERROR(version_unsupported);
 #if (ZSTD_LEGACY_SUPPORT <= 4)
         case 4 : return ZBUFFv04_freeDCtx((ZBUFFv04_DCtx*)legacyContext);
@@ -250,6 +252,7 @@ MEM_STATIC size_t ZSTD_initLegacyStream(void** legacyContext, U32 prevVersion, U
         case 1 :
         case 2 :
         case 3 :
+            (void)dict; (void)dictSize;
             return 0;
 #if (ZSTD_LEGACY_SUPPORT <= 4)
         case 4 :
@@ -306,6 +309,7 @@ MEM_STATIC size_t ZSTD_decompressLegacyStream(void* legacyContext, U32 version,
         case 1 :
         case 2 :
         case 3 :
+            (void)legacyContext; (void)output; (void)input;
             return ERROR(version_unsupported);
 #if (ZSTD_LEGACY_SUPPORT <= 4)
         case 4 :