Merge pull request #807 from facebook/poolQueue0

reduced pool queue to 0 to save memory
dev
Yann Collet 2017-08-19 22:24:42 -07:00 committed by GitHub
commit ff167705e6
3 changed files with 9 additions and 10 deletions

View File

@ -76,17 +76,13 @@ static void* POOL_thread(void* opaque) {
return opaque; return opaque;
} }
/* Pop a job off the queue */ /* 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->queueHead = (ctx->queueHead + 1) % ctx->queueSize;
ctx->numThreadsBusy++; ctx->numThreadsBusy++;
ctx->queueEmpty = ctx->queueHead == ctx->queueTail; ctx->queueEmpty = ctx->queueHead == ctx->queueTail;
/* Unlock the mutex, signal a pusher, and run the job */ /* Unlock the mutex, signal a pusher, and run the job */
pthread_mutex_unlock(&ctx->queueMutex); pthread_mutex_unlock(&ctx->queueMutex);
if (ctx->queueSize > 1) {
pthread_cond_signal(&ctx->queuePushCond); pthread_cond_signal(&ctx->queuePushCond);
}
job.function(job.opaque); job.function(job.opaque);
@ -96,9 +92,8 @@ static void* POOL_thread(void* opaque) {
ctx->numThreadsBusy--; ctx->numThreadsBusy--;
pthread_mutex_unlock(&ctx->queueMutex); pthread_mutex_unlock(&ctx->queueMutex);
pthread_cond_signal(&ctx->queuePushCond); pthread_cond_signal(&ctx->queuePushCond);
} } }
} } /* for (;;) */
}
/* Unreachable */ /* Unreachable */
} }

View File

@ -426,7 +426,7 @@ ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbThreads, ZSTD_customMem cMem)
mtctx->allJobsCompleted = 1; mtctx->allJobsCompleted = 1;
mtctx->sectionSize = 0; mtctx->sectionSize = 0;
mtctx->overlapLog = ZSTDMT_OVERLAPLOG_DEFAULT; mtctx->overlapLog = ZSTDMT_OVERLAPLOG_DEFAULT;
mtctx->factory = POOL_create(nbThreads, 1); mtctx->factory = POOL_create(nbThreads, 0);
mtctx->jobs = ZSTDMT_allocJobsTable(&nbJobs, cMem); mtctx->jobs = ZSTDMT_allocJobsTable(&nbJobs, cMem);
mtctx->jobIDMask = nbJobs - 1; mtctx->jobIDMask = nbJobs - 1;
mtctx->bufPool = ZSTDMT_createBufferPool(nbThreads, cMem); mtctx->bufPool = ZSTDMT_createBufferPool(nbThreads, cMem);

View File

@ -123,6 +123,7 @@ MEM_STATIC size_t ZSTD_decompressLegacy(
const void* dict,size_t dictSize) const void* dict,size_t dictSize)
{ {
U32 const version = ZSTD_isLegacy(src, compressedSize); U32 const version = ZSTD_isLegacy(src, compressedSize);
(void)dst; (void)dstCapacity; (void)dict; (void)dictSize; /* unused when ZSTD_LEGACY_SUPPORT >= 8 */
switch(version) switch(version)
{ {
#if (ZSTD_LEGACY_SUPPORT <= 1) #if (ZSTD_LEGACY_SUPPORT <= 1)
@ -223,6 +224,7 @@ MEM_STATIC size_t ZSTD_freeLegacyStreamContext(void* legacyContext, U32 version)
case 1 : case 1 :
case 2 : case 2 :
case 3 : case 3 :
(void)legacyContext;
return ERROR(version_unsupported); return ERROR(version_unsupported);
#if (ZSTD_LEGACY_SUPPORT <= 4) #if (ZSTD_LEGACY_SUPPORT <= 4)
case 4 : return ZBUFFv04_freeDCtx((ZBUFFv04_DCtx*)legacyContext); 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 1 :
case 2 : case 2 :
case 3 : case 3 :
(void)dict; (void)dictSize;
return 0; return 0;
#if (ZSTD_LEGACY_SUPPORT <= 4) #if (ZSTD_LEGACY_SUPPORT <= 4)
case 4 : case 4 :
@ -306,6 +309,7 @@ MEM_STATIC size_t ZSTD_decompressLegacyStream(void* legacyContext, U32 version,
case 1 : case 1 :
case 2 : case 2 :
case 3 : case 3 :
(void)legacyContext; (void)output; (void)input;
return ERROR(version_unsupported); return ERROR(version_unsupported);
#if (ZSTD_LEGACY_SUPPORT <= 4) #if (ZSTD_LEGACY_SUPPORT <= 4)
case 4 : case 4 :