Author: remm Date: Wed Jun 18 09:03:37 2014 New Revision: 1603376 URL: http://svn.apache.org/r1603376 Log: - Fix apparent issues for caches configuration (socket properties is likely not set yet, and the channel pool size was not using the right property). - Still not convinced about the usefulness of these caches even if raw benchmarks could show some slight improvements, so keep them disabled in NIO2.
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java?rev=1603376&r1=1603375&r2=1603376&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Wed Jun 18 09:03:37 2014 @@ -111,23 +111,17 @@ public class Nio2Endpoint extends Abstra /** * Cache for SocketProcessor objects */ - private final SynchronizedStack<SocketProcessor> processorCache = - new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, - socketProperties.getProcessorCache()); + private SynchronizedStack<SocketProcessor> processorCache; /** - * Cache for key attachment objects + * Cache for socket wrapper objects */ - private final SynchronizedStack<Nio2SocketWrapper> socketWrapperCache = - new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, - socketProperties.getSocketWrapperCache()); + private SynchronizedStack<Nio2SocketWrapper> socketWrapperCache; /** * Bytebuffer cache, each channel holds a set of buffers (two, except for SSL holds four) */ - private final SynchronizedStack<Nio2Channel> nioChannels = - new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, - socketProperties.getBufferPoolSize()); + private SynchronizedStack<Nio2Channel> nioChannels; // ------------------------------------------------------------- Properties @@ -356,6 +350,15 @@ public class Nio2Endpoint extends Abstra createExecutor(); } + if (useCaches) { + processorCache = new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, + socketProperties.getProcessorCache()); + socketWrapperCache = new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, + socketProperties.getSocketWrapperCache()); + nioChannels = new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, + socketProperties.getBufferPool()); + } + initializeConnectionLatch(); startAcceptorThreads(); Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1603376&r1=1603375&r2=1603376&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Wed Jun 18 09:03:37 2014 @@ -127,30 +127,22 @@ public class NioEndpoint extends Abstrac /** * Cache for SocketProcessor objects */ - private final SynchronizedStack<SocketProcessor> processorCache = - new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, - socketProperties.getProcessorCache()); + private SynchronizedStack<SocketProcessor> processorCache; /** * Cache for key attachment objects */ - private final SynchronizedStack<KeyAttachment> keyCache = - new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, - socketProperties.getKeyCache()); + private SynchronizedStack<KeyAttachment> keyCache; /** * Cache for poller events */ - private final SynchronizedStack<PollerEvent> eventCache = - new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, - socketProperties.getEventCache()); + private SynchronizedStack<PollerEvent> eventCache; /** * Bytebuffer cache, each channel holds a set of buffers (two, except for SSL holds four) */ - private final SynchronizedStack<NioChannel> nioChannels = - new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, - socketProperties.getBufferPoolSize()); + private SynchronizedStack<NioChannel> nioChannels; // ------------------------------------------------------------- Properties @@ -414,6 +406,15 @@ public class NioEndpoint extends Abstrac createExecutor(); } + processorCache = new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, + socketProperties.getProcessorCache()); + keyCache = new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, + socketProperties.getKeyCache()); + eventCache = new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, + socketProperties.getEventCache()); + nioChannels = new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE, + socketProperties.getBufferPool()); + initializeConnectionLatch(); // Start poller threads Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1603376&r1=1603375&r2=1603376&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Wed Jun 18 09:03:37 2014 @@ -197,6 +197,9 @@ HTTP connector and ensure that access log entries generated by error conditions use the correct request start time. (markt) </fix> + <fix> + Improve configuration of cache sizes in the endpoint. (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org