diff options
author | Lester Solbakken <lesters@oath.com> | 2019-03-25 14:20:07 +0100 |
---|---|---|
committer | Lester Solbakken <lesters@oath.com> | 2019-03-25 14:20:07 +0100 |
commit | 96e0eccf19f04e7394994a8ec14811bc8e1c1370 (patch) | |
tree | a7a8ebe250c26ef935b2b5b6e0a4fcdbefe8c721 /docproc | |
parent | 4f42f214d728811f5a6328973ce098731f13cbd5 (diff) |
Don't block thread pool if numthreads is > 0
Diffstat (limited to 'docproc')
-rw-r--r-- | docproc/src/main/java/com/yahoo/docproc/jdisc/DocumentProcessingHandler.java | 19 | ||||
-rw-r--r-- | docproc/src/main/resources/configdefinitions/docproc.def | 5 |
2 files changed, 17 insertions, 7 deletions
diff --git a/docproc/src/main/java/com/yahoo/docproc/jdisc/DocumentProcessingHandler.java b/docproc/src/main/java/com/yahoo/docproc/jdisc/DocumentProcessingHandler.java index 18c3cbadd3a..07efd419c97 100644 --- a/docproc/src/main/java/com/yahoo/docproc/jdisc/DocumentProcessingHandler.java +++ b/docproc/src/main/java/com/yahoo/docproc/jdisc/DocumentProcessingHandler.java @@ -90,11 +90,7 @@ public class DocumentProcessingHandler extends AbstractRequestHandler { DocumentProcessingHandlerParameters params) { this(docprocServiceRegistry, documentProcessorComponentRegistry, docFactoryRegistry, new DocprocThreadPoolExecutor(params.getMaxNumThreads(), - (params.getMaxQueueTimeMs() > 0) - ? new ThroughputLimitQueue<>(params.getMaxQueueTimeMs()) - : (params.getMaxQueueTimeMs() < 0) - ? new SynchronousQueue<>() - : new PriorityBlockingQueue<>(), //Probably no need to bound this queue, see bug #4254537 + chooseQueueType(params), new DocprocThreadManager(params.getMaxConcurrentFactor(), params.getDocumentExpansionFactor(), params.getContainerCoreMemoryMb(), @@ -106,6 +102,19 @@ public class DocumentProcessingHandler extends AbstractRequestHandler { params.getContainerDocConfig()); } + private static BlockingQueue<Runnable> chooseQueueType(DocumentProcessingHandlerParameters params) { + if (params.getMaxQueueTimeMs() > 0) { + return new ThroughputLimitQueue<>(params.getMaxQueueTimeMs()); + } + if (params.getMaxQueueTimeMs() == 0) { + return new PriorityBlockingQueue<>(); // Probably no need to bound this queue, see bug #4254537 + } + if (params.getMaxNumThreads() > 0) { + return new LinkedBlockingQueue<>(); + } + return new SynchronousQueue<>(); + } + @Inject public DocumentProcessingHandler(ComponentRegistry<DocumentProcessor> documentProcessorComponentRegistry, ComponentRegistry<AbstractConcreteDocumentFactory> docFactoryRegistry, diff --git a/docproc/src/main/resources/configdefinitions/docproc.def b/docproc/src/main/resources/configdefinitions/docproc.def index 396e204054e..645fbcce1b7 100644 --- a/docproc/src/main/resources/configdefinitions/docproc.def +++ b/docproc/src/main/resources/configdefinitions/docproc.def @@ -4,8 +4,9 @@ namespace=config.docproc # Queue size (in milliseconds) for this node # Positive size gives a ThroughPutLimitQueue. ### Experimental. # 0 Gives a PriorityQueue -# Negative values gives a SynchronousQueue, in effect increasing number of threads as required (if numthreads == -1) +# Negative values gives a SynchronousQueue if numthreads <= 0 (which increases thread pool size as required), +# otherwise a LinkedBlockingQueue maxqueuetimems int default=-1 -#The number of threads in the DocprocHandler worker thread pool +# The number of threads in the DocprocHandler worker thread pool numthreads int default=-1 |