[
https://issues.apache.org/jira/browse/QPIDJMS-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17434859#comment-17434859
]
ASF GitHub Bot commented on QPIDJMS-552:
----------------------------------------
gemmellr commented on a change in pull request #44:
URL: https://github.com/apache/qpid-jms/pull/44#discussion_r736741170
##########
File path: qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java
##########
@@ -215,6 +259,17 @@ public void close() throws JMSException {
connectionConsumer.shutdown();
}
+ final ThreadPoolExecutor completionExecutor =
this.completionExecutor;
+
Review comment:
No need for newline here, its all one unit.
##########
File path: qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java
##########
@@ -194,6 +193,42 @@ public void onPendingFailure(ProviderException cause) {
}
}
+ private void processCompletions() {
+ do {
+ if (!completionThread.compareAndSet(null, Thread.currentThread()))
{
+ return;
+ }
+ try {
+ Runnable completionTask;
+ while ((completionTask = completionTasks.poll()) != null) {
+ try {
+ completionTask.run();
+ } catch (Throwable t) {
+ LOG.debug("errored on processCompletions duty cycle",
t);
+ }
+ }
+ } finally {
+ completionThread.set(null);
+ }
+ } while (!completionTasks.isEmpty());
Review comment:
The queue used was explicitly single-consumer, to which its doc adds a
"one thread!" note. This line will be potentially executable concurrently (with
both itself, and with the poll in the loop) since the thread ref is nulled
before the loop check, meaning a second (or more) thread can technically get
into the loop as another completes and potentially also then exit it and have
more than one at this point too. Can the queue handle that?
##########
File path: qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java
##########
@@ -71,6 +69,7 @@
import javax.jms.TopicSession;
import javax.jms.TopicSubscriber;
+import io.netty.util.internal.PlatformDependent;
Review comment:
I don't like it using Netty internal APIs.
##########
File path: qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java
##########
@@ -183,6 +189,44 @@ JmsConnection connect() throws JMSException {
return this;
}
+ ExecutorService getCompletionExecutor() {
+ ThreadPoolExecutor exec = completionExecutor;
+ if (exec == null) {
+ synchronized (this) {
+ exec = completionExecutor;
+ if (exec == null) {
+ // it can grow "unbounded" to serve multiple concurrent
session completions:
+ // in reality it is bounded by the amount of concurrent
completion requests
+ exec = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 5,
TimeUnit.SECONDS, new LinkedTransferQueue<>(),
+ new
QpidJMSThreadFactory("JmsConnection ["+ connectionInfo.getId() + "] completion
dispatcher", connectionInfo.isUseDaemonThread()));
Review comment:
These threads will all end up having the same name when operating even
if there are many at once, and as they come and go over time, which could be
confusing. Adding some kind of index might be an idea, though I guess that
could also look odd if it just always increases if they come and go (and the
thread factory would need changed to accommodate it, its aimed at single thread
creation)
Previously they were named based on their individual session. It might be
good to at least reinstate that name while operating for a given session?
I think I might be inclined to have core size be 1. The executor wont be
created until it is needed during cleanup or if they use completions in which
case it is needed.
##########
File path: qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java
##########
@@ -194,6 +193,42 @@ public void onPendingFailure(ProviderException cause) {
}
}
+ private void processCompletions() {
+ do {
+ if (!completionThread.compareAndSet(null, Thread.currentThread()))
{
+ return;
+ }
+ try {
Review comment:
Newline would be nice before this, distinct units.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
> JMS 2 Completion threads shouldn't scale with the number of sessions
> --------------------------------------------------------------------
>
> Key: QPIDJMS-552
> URL: https://issues.apache.org/jira/browse/QPIDJMS-552
> Project: Qpid JMS
> Issue Type: Bug
> Components: qpid-jms-client
> Affects Versions: 1.3.0
> Reporter: Francesco Nigro
> Priority: Major
>
> JMS 2 Completion threads are now tied to be one per JMS Session ie a client
> application with N JMS sessions need N completion threads to handle the
> completion events.
> Given that the asynchronous model of JMS 2 allows users to have few threads
> handling many JMS sessions, should be better to reduce the amount of
> completion threads without exceeding the number of available cores and
> shrink/grow according to the completion event processing load.
> If the user confine a connection in a thread handling many JMS sessions and
> the completion events are issued by the same Netty thread in sequence, if the
> completion processing for a JMS Session is fast enough, next JMS Sessions can
> reuse existing completion threads instead of using a new one.
> This model save using too many completion threads for users tasks that are
> supposed to be very fast: if the user task cause a specific JMS Session
> completion thread to block, the expectation is that the system should be able
> to create a new completion thread to handle other JMS Session completion
> events, as expected.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]