https://bz.apache.org/bugzilla/show_bug.cgi?id=64155
Bug ID: 64155 Summary: Tomcat 7 Performance: acceptor thread bottleneck at getPoolSize() located at TaskQueue offer function Product: Tomcat 7 Version: trunk Hardware: All Status: NEW Severity: normal Priority: P2 Component: Catalina Assignee: dev@tomcat.apache.org Reporter: torres.y...@broadcom.com Target Milestone: --- Created attachment 37022 --> https://bz.apache.org/bugzilla/attachment.cgi?id=37022&action=edit Reduced getPoolSize Tomcat 7 Performance: During our performance testing, we found out that the acceptor thread bottleneck at the getPoolSize() located at TaskQueue offer function, which is an expensive call to AbstractQueuedSynchronizer acquire lock. Proposed fix is to store and use poolSize as local variable. This reduces 2-3 expensive calls down to 1 for each request. @Override public boolean offer(Runnable o) { //we can't do any checks if (parent == null) return super.offer(o); // getPoolSize() is expensive call to AbstractQueuedSynchronizer acquire lock final int poolSize = parent.getPoolSize(); //we are maxed out on threads, simply queue the object if (poolSize == parent.getMaximumPoolSize()) return super.offer(o); //we have idle threads, just add it to the queue if (parent.getSubmittedCount() <= poolSize) return super.offer(o); //if we have less threads than maximum force creation of a new thread if (poolSize < parent.getMaximumPoolSize()) return false; //if we reached here, we need to add it to the queue return super.offer(o); } -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org