mirror of
https://github.com/facebook/zstd.git
synced 2025-03-07 09:26:03 +02:00
reduced pool queue to 0 to save memory
fixed : pool performance when jobs are fires fast and queueSize==0
This commit is contained in:
parent
f7312a7cb4
commit
7db552676e
@ -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 */
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 :
|
||||
|
Loading…
x
Reference in New Issue
Block a user