This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new 9116e05 Change NIO poller thread count default to 1 9116e05 is described below commit 9116e05bd04099512312993a27f89b74689b142a Author: remm <r...@apache.org> AuthorDate: Fri Apr 19 11:25:10 2019 +0200 Change NIO poller thread count default to 1 I don't see the benefit of the weird default (which is basically always 2, and I don't understand why it is better than 1). Maybe it was useful in the past. Given a socket is associated with a poller, if something (somehow) goes wrong, then this would create a partially responsive server which is not really better but makes problems harder to detect. If I missed something, I am 100% ok to revert it (but I would be interested in the performance study that says 2 is better than 1 here). --- java/org/apache/tomcat/util/net/NioEndpoint.java | 10 +++++++--- webapps/docs/changelog.xml | 4 ++++ webapps/docs/config/http.xml | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index e84a34f..0df2846 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -147,7 +147,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> /** * Poller thread count. */ - private int pollerThreadCount = Math.min(2,Runtime.getRuntime().availableProcessors()); + private int pollerThreadCount = 1; public void setPollerThreadCount(int pollerThreadCount) { this.pollerThreadCount = pollerThreadCount; } public int getPollerThreadCount() { return pollerThreadCount; } @@ -166,8 +166,12 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> * @return The next poller in sequence */ public Poller getPoller0() { - int idx = Math.abs(pollerRotater.incrementAndGet()) % pollers.length; - return pollers[idx]; + if (pollerThreadCount == 1) { + return pollers[0]; + } else { + int idx = Math.abs(pollerRotater.incrementAndGet()) % pollers.length; + return pollers[idx]; + } } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 9992f8a..34fcdee 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -109,6 +109,10 @@ When running on newer JREs that don't support SSLv2Hello, don't warn that it is not available unless explicitly configured. (markt) </fix> + <fix> + Change default value of <code>pollerThreadCount</code> of NIO + to <code>1</code>. (remm) + </fix> </changelog> </subsection> </section> diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml index 9e68e39..039335d 100644 --- a/webapps/docs/config/http.xml +++ b/webapps/docs/config/http.xml @@ -735,7 +735,7 @@ <attribute name="pollerThreadCount" required="false"> <p>(int)The number of threads to be used to run for the polling events. - Default value is <code>1</code> per processor but not more than 2.<br/> + Default value is <code>1</code>.<br/> When accepting a socket, the operating system holds a global lock. So the benefit of going above 2 threads diminishes rapidly. Having more than one thread is for system that need to accept connections very rapidly. However usually just --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org