You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2008/01/14 19:28:37 UTC

svn commit: r611877 - in /tomcat/connectors/trunk/jk: native/common/jk_lb_worker.c native/common/jk_lb_worker.h xdocs/miscellaneous/changelog.xml

Author: rjung
Date: Mon Jan 14 10:28:34 2008
New Revision: 611877

URL: http://svn.apache.org/viewvc?rev=611877&view=rev
Log:
Optimize state macros n LB to improve performance.
The new macros are equivalent to the old ones, as long
as the constant value sused are sorted correctly.
The new macros should be faster, because they contain
fewer comparisons.

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
    tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h
    tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml

Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c?rev=611877&r1=611876&r2=611877&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Mon Jan 14 10:28:34 2008
@@ -40,8 +40,18 @@
  * The load balancing code in this
  */
 
-#define JK_WORKER_USABLE(w)   ((w)->s->state != JK_LB_STATE_ERROR && (w)->s->state != JK_LB_STATE_PROBE && (w)->s->state != JK_LB_STATE_BUSY && (w)->activation != JK_LB_ACTIVATION_STOPPED && (w)->activation != JK_LB_ACTIVATION_DISABLED)
-#define JK_WORKER_USABLE_STICKY(w)   ((w)->s->state != JK_LB_STATE_ERROR && (w)->s->state != JK_LB_STATE_PROBE && (w)->activation != JK_LB_ACTIVATION_STOPPED)
+/*
+ * The following two macros need to be kept in sync with
+ * the existing values for state and activation.
+ * Note: state <= JK_LB_STATE_FORCE is equivalent to
+ *       state is none of JK_LB_STATE_BUSY, JK_LB_STATE_ERROR, JK_LB_STATE_PROBE
+ * Note: state <= JK_LB_STATE_BUSY is equivalent to
+ *       state is none of JK_LB_STATE_ERROR, JK_LB_STATE_PROBE
+ * Note: activation == JK_LB_ACTIVATION_ACTIVE is equivalent to
+ *       activation is none of JK_LB_ACTIVATION_STOPPED, JK_LB_ACTIVATION_DISABLED
+ */
+#define JK_WORKER_USABLE(w)   ((w)->s->state <= JK_LB_STATE_FORCE && (w)->activation == JK_LB_ACTIVATION_ACTIVE)
+#define JK_WORKER_USABLE_STICKY(w)   ((w)->s->state <= JK_LB_STATE_BUSY && (w)->activation != JK_LB_ACTIVATION_STOPPED)
 
 static const char *lb_locking_type[] = {
     JK_LB_LOCK_TEXT_OPTIMISTIC,

Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h?rev=611877&r1=611876&r2=611877&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.h Mon Jan 14 10:28:34 2008
@@ -58,20 +58,27 @@
 #define JK_LB_LOCK_TEXT_OPTIMISTIC     ("Optimistic")
 #define JK_LB_LOCK_TEXT_PESSIMISTIC    ("Pessimistic")
 #define JK_LB_LOCK_TEXT_DEF            (JK_LB_LOCK_TEXT_OPTIMISTIC)
+/*
+ * The following definitions for state and activation
+ * need to be kept in sync with the two macros 
+ * JK_WORKER_USABLE() and JK_WORKER_USABLE_STICKY() in jk_lb_worker.c.
+ * Since we use ordered comparisons there instead of multiple
+ * equal/unequal compares, order of the values is critical here.
+ */
 #define JK_LB_STATE_IDLE               (0)
 #define JK_LB_STATE_OK                 (1)
 #define JK_LB_STATE_RECOVER            (2)
-#define JK_LB_STATE_BUSY               (3)
-#define JK_LB_STATE_ERROR              (4)
-#define JK_LB_STATE_FORCE              (5)
+#define JK_LB_STATE_FORCE              (3)
+#define JK_LB_STATE_BUSY               (4)
+#define JK_LB_STATE_ERROR              (5)
 #define JK_LB_STATE_PROBE              (6)
 #define JK_LB_STATE_DEF                (JK_LB_STATE_IDLE)
 #define JK_LB_STATE_TEXT_IDLE          ("OK/IDLE")
 #define JK_LB_STATE_TEXT_OK            ("OK")
 #define JK_LB_STATE_TEXT_RECOVER       ("ERR/REC")
 #define JK_LB_STATE_TEXT_BUSY          ("OK/BUSY")
-#define JK_LB_STATE_TEXT_ERROR         ("ERR")
 #define JK_LB_STATE_TEXT_FORCE         ("ERR/FRC")
+#define JK_LB_STATE_TEXT_ERROR         ("ERR")
 #define JK_LB_STATE_TEXT_PROBE         ("ERR/PRB")
 #define JK_LB_STATE_TEXT_MAX           (JK_LB_STATE_PROBE)
 #define JK_LB_STATE_TEXT_DEF           (JK_LB_STATE_TEXT_IDLE)

Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?rev=611877&r1=611876&r2=611877&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Mon Jan 14 10:28:34 2008
@@ -44,6 +44,9 @@
   <subsection name="Native">
     <changelog>
       <update>
+        LB: Optimize state macros to improve performance. (rjung)
+      </update>
+      <update>
         Apache: Allow dynamic setting of reply timeout using the environment
         variable JK_REPLY_TIMEOUT. (rjung)
       </update>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org