Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8A97E1012B for ; Tue, 1 Oct 2013 18:43:34 +0000 (UTC) Received: (qmail 78079 invoked by uid 500); 1 Oct 2013 18:43:28 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 78029 invoked by uid 500); 1 Oct 2013 18:43:28 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 78020 invoked by uid 99); 1 Oct 2013 18:43:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Oct 2013 18:43:28 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Oct 2013 18:43:25 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id EFA652388BA6 for ; Tue, 1 Oct 2013 18:43:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1528176 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/tomcat/util/net/AprEndpoint.java Date: Tue, 01 Oct 2013 18:43:04 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131001184304.EFA652388BA6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org