Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 12407 invoked from network); 3 Apr 2002 09:01:53 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 3 Apr 2002 09:01:53 -0000 Received: (qmail 24876 invoked by uid 97); 3 Apr 2002 09:01:51 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@jakarta.apache.org Received: (qmail 24750 invoked by uid 97); 3 Apr 2002 09:01:50 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 24663 invoked from network); 3 Apr 2002 09:01:49 -0000 From: "Arvind Srinivasan" To: "Tomcat Developers List" Subject: RE: cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core StandardPipeline.java Date: Wed, 3 Apr 2002 01:10:27 -0800 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_057A_01C1DAAC.574DC870" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ------=_NextPart_000_057A_01C1DAAC.574DC870 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi Remy, I think the performance related change that you made to StandardPipeline can be improved upon in that it can avoid using a HashMap to store/retrieve the pipeline stage and instead simply store/retrieve it from an integer variable in the RequestBase class. Since this codepath (StandardPipeline.invokeNext) is executed many times per request, replacing the request.getNote() call with something like request.getPipelineStage() will benefit performance. I've attached a patch that implements this suggestion. Thanks, Arvind > remm 02/03/31 20:19:55 > > Modified: catalina/src/share/org/apache/catalina/core > StandardPipeline.java > Log: > - Use a note in the request instead of a ThreadLocal to keep > track of the > pipeline stage. > Note: This could cause problems with a valve that would wrap > the request, > and not delegate the getNote method to the wrapped request. > ------=_NextPart_000_057A_01C1DAAC.574DC870 Content-Type: text/plain; name="pipeline-patch.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pipeline-patch.txt" Index: catalina/src/share/org/apache/catalina/Request.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina= /Request.java,v retrieving revision 1.5 diff -u -r1.5 Request.java --- catalina/src/share/org/apache/catalina/Request.java 1 Aug 2001 = 03:04:04 -0000 1.5 +++ catalina/src/share/org/apache/catalina/Request.java 3 Apr 2002 = 08:40:02 -0000 @@ -210,6 +210,22 @@ public void setWrapper(Wrapper wrapper); =20 =20 + /** + * Set the index of the (next) valve (in the pipeline) that will = process + * this request. + * + * @param stage The position of the next valve (in the pipeline) + */ + public void setPipelineStage(int stage); + + + /** + * Return the index (in the pipeline) of the valve that is to = process + * this request. + */ + public int getPipelineStage(); + + // --------------------------------------------------------- Public = Methods =20 =20 Index: catalina/src/share/org/apache/catalina/connector/RequestBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina= /connector/RequestBase.java,v retrieving revision 1.18 diff -u -r1.18 RequestBase.java --- catalina/src/share/org/apache/catalina/connector/RequestBase.java 18 = Mar 2002 07:15:39 -0000 1.18 +++ catalina/src/share/org/apache/catalina/connector/RequestBase.java 3 = Apr 2002 08:40:02 -0000 @@ -270,6 +270,13 @@ protected Wrapper wrapper =3D null; =20 =20 + /** + * The index (in the pipeline) of the valve that is processing/will + * process this request. + */ + protected int _stage =3D 0; + + // ------------------------------------------------------------- = Properties =20 =20 @@ -455,6 +462,26 @@ =20 this.wrapper =3D wrapper; =20 + } + + + /** + * Set the index of the (next) valve (in the pipeline) that will = process + * this request. + * + * @param stage The position of the next valve (in the pipeline) + */ + public void setPipelineStage(int stage) { + _stage =3D stage; + } + + + /** + * Return the index (in the pipeline) of the valve that is to = process + * this request. + */ + public int getPipelineStage() { + return _stage; } =20 =20 Index: catalina/src/share/org/apache/catalina/core/StandardPipeline.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina= /core/StandardPipeline.java,v retrieving revision 1.5 diff -u -r1.5 StandardPipeline.java --- catalina/src/share/org/apache/catalina/core/StandardPipeline.java 1 = Apr 2002 04:19:54 -0000 1.5 +++ catalina/src/share/org/apache/catalina/core/StandardPipeline.java 3 = Apr 2002 08:40:02 -0000 @@ -100,12 +100,6 @@ implements Pipeline, Contained, Lifecycle, ValveContext { =20 =20 - // -------------------------------------------------------------- = Constants - - - protected static final String STATE =3D "pipelineState"; - - // ----------------------------------------------------------- = Constructors =20 =20 @@ -472,8 +466,9 @@ public void invoke(Request request, Response response) throws IOException, ServletException { =20 - // Initialize the per-thread state for this thread - request.setNote(STATE, new PipelineState()); + // Indicate that the first valve in the pipeline should process + // this request + request.setPipelineStage(0); =20 // Invoke the first Valve in this pipeline for this request invokeNext(request, response); @@ -561,10 +556,10 @@ public void invokeNext(Request request, Response response) throws IOException, ServletException { =20 - // Identify the current subscript for the current request = thread - PipelineState pipelineState =3D (PipelineState) = request.getNote(STATE); - int subscript =3D pipelineState.stage; - pipelineState.stage =3D pipelineState.stage + 1; + // Increment the stage so that the next valve in the pipeline + // can process the request + int subscript =3D request.getPipelineStage(); + request.setPipelineStage(subscript + 1); =20 // Invoke the requested Valve for the current request thread if (subscript < valves.length) { ------=_NextPart_000_057A_01C1DAAC.574DC870 Content-Type: text/plain; charset=us-ascii -- To unsubscribe, e-mail: For additional commands, e-mail: ------=_NextPart_000_057A_01C1DAAC.574DC870--