You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by lu...@apache.org on 2003/08/13 02:13:43 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5 CoyoteResponse.java

luehe       2003/08/12 17:13:43

  Modified:    catalina/src/share/org/apache/coyote/tomcat5
                        CoyoteResponse.java
  Log:
  Optimizations:
  
  - Bugtraq 4730584 ("HttpResponseBase should create date format only
    when needed")
  
  - Bugtraq 4701695 ("avoid reformatting constant Expires header on every
    request")
  
  Revision  Changes    Path
  1.6       +22 -12    jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/CoyoteResponse.java
  
  Index: CoyoteResponse.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/CoyoteResponse.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CoyoteResponse.java	23 Jun 2003 19:14:41 -0000	1.5
  +++ CoyoteResponse.java	13 Aug 2003 00:13:43 -0000	1.6
  @@ -113,7 +113,7 @@
   import org.apache.catalina.util.CharsetMapper;
   import org.apache.catalina.util.RequestUtil;
   import org.apache.catalina.util.StringManager;
  -
  +import org.apache.catalina.util.DateTool;
   
   /**
    * Wrapper object for the Coyote response.
  @@ -131,10 +131,7 @@
   
   
       public CoyoteResponse() {
  -
  -        format.setTimeZone(TimeZone.getTimeZone("GMT"));
           urlEncoder.addSafeCharacter('/');
  -
       }
   
   
  @@ -143,8 +140,7 @@
       /**
        * The date format we will use for creating date headers.
        */
  -    protected final SimpleDateFormat format =
  -        new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
  +    protected SimpleDateFormat format = null;
   
   
       /**
  @@ -939,8 +935,15 @@
               return;
   
           // Ignore any call from an included servlet
  -        if (included)
  +        if (included) {
               return;
  +        }
  +
  +        if (format == null) {
  +            format = new SimpleDateFormat(DateTool.HTTP_RESPONSE_DATE_HEADER,
  +                                          Locale.US);
  +            format.setTimeZone(TimeZone.getTimeZone("GMT"));
  +        }
   
           addHeader(name, FastHttpDateFormat.formatDate(value, format));
   
  @@ -1190,8 +1193,15 @@
               return;
   
           // Ignore any call from an included servlet
  -        if (included)
  +        if (included) {
               return;
  +        }
  +
  +        if (format == null) {
  +            format = new SimpleDateFormat(DateTool.HTTP_RESPONSE_DATE_HEADER,
  +                                          Locale.US);
  +            format.setTimeZone(TimeZone.getTimeZone("GMT"));
  +        }
   
           setHeader(name, FastHttpDateFormat.formatDate(value, format));
   
  
  
  

Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5 CoyoteResponse.java

Posted by Bill Barker <wb...@wilshire.com>.
----- Original Message -----
From: <lu...@apache.org>
To: <ja...@apache.org>
Sent: Tuesday, August 12, 2003 5:13 PM
Subject: cvs commit:
jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5
CoyoteResponse.java


> luehe       2003/08/12 17:13:43
>
>   Modified:    catalina/src/share/org/apache/coyote/tomcat5
>                         CoyoteResponse.java
>   Log:
>   Optimizations:
>
>   - Bugtraq 4730584 ("HttpResponseBase should create date format only
>     when needed")
>
>   - Bugtraq 4701695 ("avoid reformatting constant Expires header on every
>     request")

The CoyoteResponse is a pretty long-living object.  I wouldn't expect that
this will speed Tomcat up at all once it has been running for a while.


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5 CoyoteResponse.java

Posted by Remy Maucherat <re...@apache.org>.
luehe@apache.org wrote:
> luehe       2003/08/12 17:13:43
> 
>   Modified:    catalina/src/share/org/apache/coyote/tomcat5
>                         CoyoteResponse.java
>   Log:
>   Optimizations:
>   
>   - Bugtraq 4730584 ("HttpResponseBase should create date format only
>     when needed")
>   
>   - Bugtraq 4701695 ("avoid reformatting constant Expires header on every
>     request")

Those are two useless optimizations:

- Since when do you care about creating an object ? Lazy initialization 
is useless since its lifecycle is tied to the connector lifecyle (ie, 
very long); it is also only used in case of a cache miss, to decrease a 
bit the concurrency on the formatting operation.

- Well, it removes a cache lookup; not a very big deal ...

There were big performance problems in the Catalina code before 5.0.x. 
Now I believe the main pipeline is clean, and further gains will be 
anecdotical (ie, don't bother). To determine if something is a hotspot, 
I recommend using OptimizeIt. If you really want to optimize something, 
there are parts which can be worked on, such as BASIC auth (and DIGEST 
also), where you should take advantage of the fact that you can use a 
byte array directly rather than strings.

Remy


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5 CoyoteResponse.java

Posted by Remy Maucherat <re...@apache.org>.
luehe@apache.org wrote:
> luehe       2003/08/12 17:13:43
> 
>   Modified:    catalina/src/share/org/apache/coyote/tomcat5
>                         CoyoteResponse.java
>   Log:
>   Optimizations:
>   
>   - Bugtraq 4730584 ("HttpResponseBase should create date format only
>     when needed")
>   
>   - Bugtraq 4701695 ("avoid reformatting constant Expires header on every
>     request")

Those are two useless optimizations:

- Since when do you care about creating an object ? Lazy initialization 
is useless since its lifecycle is tied to the connector lifecyle (ie, 
very long); it is also only used in case of a cache miss, to decrease a 
bit the concurrency on the formatting operation.

- Well, it removes a cache lookup; not a very big deal ...

There were big performance problems in the Catalina code before 5.0.x. 
Now I believe the main pipeline is clean, and further gains will be 
anecdotical (ie, don't bother). To determine if something is a hotspot, 
I recommend using OptimizeIt. If you really want to optimize something, 
there are parts which can be worked on, such as BASIC auth (and DIGEST 
also), where you should take advantage of the fact that you can use a 
byte array directly rather than strings.

Remy


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