You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Ben Peter <bp...@zentropypartners.com> on 2002/04/13 08:35:43 UTC

[PATCH] t2 main servlet performance (minor)

Hi,

in Turbine's doGet(), two spots may improve performance:

1.) A SessionValidator instance is obtained from ActionLoader and never used again.
If the call has no side-effects that are wanted, it can be safely removed.

2.) The check for firstDoGet is faster if the first (unsynchronized) call is 
made within the doGet() method, as it won't add the overhead of a method call 
if not needed.

Attached patch is against t2's CVS HEAD, if my opinion is shared.

Cheers,
Ben

-- 
Benjamin Peter                                          +49-69-96244395
Application Engineer                             Moerfelder Landstr. 55
(zentropy:partners)                            60598 Frankfurt, Germany

Re: [PATCH] t2 main servlet performance (minor)

Posted by John McNally <jm...@collab.net>.
I applied this patch.  Not sure that I responded, though.  So sorry if I
am repeating myself.  I also applied relevant parts to t3.

john mcnally

On Fri, 2002-04-12 at 23:35, Ben Peter wrote:
> Hi,
> 
> in Turbine's doGet(), two spots may improve performance:
> 
> 1.) A SessionValidator instance is obtained from ActionLoader and never used again.
> If the call has no side-effects that are wanted, it can be safely removed.
> 
> 2.) The check for firstDoGet is faster if the first (unsynchronized) call is 
> made within the doGet() method, as it won't add the overhead of a method call 
> if not needed.
> 
> Attached patch is against t2's CVS HEAD, if my opinion is shared.
> 
> Cheers,
> Ben
> 
> -- 
> Benjamin Peter                                          +49-69-96244395
> Application Engineer                             Moerfelder Landstr. 55
> (zentropy:partners)                            60598 Frankfurt, Germany
> ----
> 

> Index: src/java/org/apache/turbine/Turbine.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-2/src/java/org/apache/turbine/Turbine.java,v
> retrieving revision 1.13
> diff -u -r1.13 Turbine.java
> --- src/java/org/apache/turbine/Turbine.java	29 Mar 2002 15:57:03 -0000	1.13
> +++ src/java/org/apache/turbine/Turbine.java	13 Apr 2002 03:48:35 -0000
> @@ -71,7 +71,6 @@
>  import org.apache.stratum.lifecycle.Initializable;
>  import org.apache.turbine.modules.ActionLoader;
>  import org.apache.turbine.modules.PageLoader;
> -import org.apache.turbine.modules.actions.sessionvalidator.SessionValidator;
>  import org.apache.turbine.util.DynamicURI;
>  import org.apache.turbine.util.Log;
>  import org.apache.turbine.util.RunData;
> @@ -284,29 +283,26 @@
>       */
>      public final void init(RunData data)
>      {
> -        if (firstDoGet)
> +        synchronized (Turbine.class)
>          {
> -            synchronized (Turbine.class)
> +            if (firstDoGet)
>              {
> -                if (firstDoGet)
> -                {
> -                    serverName = data.getRequest().getServerName();
> -                    serverPort = Integer.toString(data.getRequest().getServerPort());
> -                    serverScheme = data.getRequest().getScheme();
> -
> -                    // Store the context path for tools like ContentURI and
> -                    // the UIManager that use webapp context path information
> -                    // for constructing URLs.
> -                    contextPath = data.getRequest().getContextPath();
> -
> -                    log("Turbine: Starting HTTP initialization of services");
> -                    TurbineServices.getInstance().initServices(data);
> -                    log("Turbine: Completed HTTP initialization of services");
> -
> -                    // Mark that we're done.
> -                    firstDoGet = false;
> -               }
> -            }
> +                serverName = data.getRequest().getServerName();
> +                serverPort = Integer.toString(data.getRequest().getServerPort());
> +                serverScheme = data.getRequest().getScheme();
> +
> +                // Store the context path for tools like ContentURI and
> +                // the UIManager that use webapp context path information
> +                // for constructing URLs.
> +                contextPath = data.getRequest().getContextPath();
> +
> +                log("Turbine: Starting HTTP initialization of services");
> +                TurbineServices.getInstance().initServices(data);
> +                log("Turbine: Completed HTTP initialization of services");
> +
> +                // Mark that we're done.
> +                firstDoGet = false;
> +           }
>          }
>      }
>  
> @@ -397,7 +393,10 @@
>              // If this is the first invocation, perform some
>              // initialization.  Certain services need RunData to initialize
>              // themselves.
> -            init(data);
> +            if ( firstDoGet )
> +            {
> +                init(data);
> +            }
>  
>              // set the session timeout if specified in turbine's properties
>              // file if this is a new session
> @@ -413,11 +412,6 @@
>              // Fill in the screen and action variables.
>              data.setScreen ( data.getParameters().getString("screen") );
>              data.setAction ( data.getParameters().getString("action") );
> -
> -            // Get the instance of the Session Validator.
> -            SessionValidator sessionValidator = (SessionValidator)ActionLoader
> -                .getInstance().getInstance(TurbineResources.getString(
> -                    "action.sessionvalidator"));
>  
>              // Special case for login and logout, this must happen before the
>              // session validator is executed in order either to allow a user to
> 
> ----
> 

> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>