[jboss-jira] [JBoss JIRA] (JGRP-2099) TP: one single thread pool
Dan Berindei (JIRA)
issues at jboss.org
Thu Sep 8 07:09:01 EDT 2016
[ https://issues.jboss.org/browse/JGRP-2099?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13290455#comment-13290455 ]
Dan Berindei commented on JGRP-2099:
------------------------------------
If you want to use a single thread pool, I recommend looking into {{ForkJoinPool}} - that's the one I'm thinking of switching Infinispan to.
One of the things I like about FJP is that when you have to block, you can use {{ManagedBlocker}} to tell the pool it should allocate a new thread.
FJP is also much better than using a classical {{ThreadPoolExecutor}} with a {{SynchronousQueue}} when it comes to context switches: {{SQ.add()}} has to block until a worker thread is free, so for each task either the submitter wakes up a worker, or the submitter parks, then a worker finishes a task and wakes up the submitter. When you use a FJP pool, and the submitter thread is from the same FJP, it will just add the task to its own queue, and the task may be processed without involving any other threads.
I've read a long time ago about about an extreme version of this, a variation of {{WithinThreadExecutor}} that queues the task in a thread-local and always runs the tasks on the same thread. (Well, if you run on your own {{Thread}} subclass, you don't technically need a thread-local.) Sounds very interesting, but I think the FJP approach is more practical :)
> TP: one single thread pool
> --------------------------
>
> Key: JGRP-2099
> URL: https://issues.jboss.org/browse/JGRP-2099
> Project: JGroups
> Issue Type: Feature Request
> Reporter: Bela Ban
> Assignee: Bela Ban
> Fix For: 4.0
>
>
> Currently, TP has 4 thread pools:
> * OOB
> * Regular
> * Internal
> * Timer (used by TimeScheduler3)
> The reason for this was mainly to prevent certain types of tasks from getting dropped due to a full pool. However, this can be changed by (1) making the pool have no queue and (2) handling the RejectedExecutionException (e.g. by spawning a new thread, or upping the max-threads value) for (e.g.) INTERNAL messages and timer tasks.
> This not only simplify configuration (1 config section rather than 4), but also reduces the size of TP (removal of accessors, attributes). Things might also become a bit faster as a result.
> The new common pool would have the following characteristics:
> * Default rejection policy of "abort" (so we can handle pool exhaustion)
> * No queue ({{SynchronousQueue}}), so new threads up to max-threads are created if none of the existing ones are available. The queue config attribute will be removed
> * Catch RejectedExecutionException for INTERNAL messages and timer tasks. A new thread will be spawned on a RejectedExecutionException. This will be used mainly by INTERNAL messages and timer tasks
> * Alternatively, we could increase max-threads (if {{ergonomics==true}}) if we get a constant rate of these exceptions
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list