Author: markt Date: Tue Oct 1 18:43:04 2013 New Revision: 1528176 URL: http://svn.apache.org/r1528176 Log: Address issue reported with high CPU usage under low load load.
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1528171 Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1528176&r1=1528175&r2=1528176&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Tue Oct 1 18:43:04 2013 @@ -1274,6 +1274,13 @@ public class AprEndpoint extends Abstrac protected int pollerTime; /** + * Variable poller timeout that adjusts depending on how many poll sets + * are in use so that the total poll time across all poll sets remains + * equal to pollTime. + */ + private int nextPollerTime; + + /** * Root pool. */ protected long pool = 0; @@ -1361,6 +1368,7 @@ public class AprEndpoint extends Abstrac pollerCount = defaultPollerSize / actualPollerSize; pollerTime = pollTime / pollerCount; + nextPollerTime = pollerTime; pollers = new long[pollerCount]; pollers[0] = pollset; @@ -1735,7 +1743,18 @@ public class AprEndpoint extends Abstrac int rv = 0; // Iterate on each pollers, but no need to poll empty pollers if (pollerSpace[i] < actualPollerSize) { - rv = Poll.poll(pollers[i], pollerTime, desc, true); + rv = Poll.poll(pollers[i], nextPollerTime, desc, true); + // Reset the nextPollerTime + nextPollerTime = pollerTime; + } else { + // Skipping an empty poll set means skipping a wait + // time of pollerTime microseconds. If most of the + // poll sets are skipped then this loop will be + // tighter than expected which could lead to higher + // than expected CPU usage. Extending the + // nextPollerTime ensures that this loop always + // takes about the same time to execute. + nextPollerTime += pollerTime; } if (rv > 0) { pollerSpace[i] += rv; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org