On Sun, 9 Jun 2002, Arvind Srinivasan wrote:

> Date: Sun, 09 Jun 2002 23:36:47 -0700
> From: Arvind Srinivasan <[EMAIL PROTECTED]>
> Reply-To: Tomcat Developers List <[EMAIL PROTECTED]>,
>      [EMAIL PROTECTED]
> To: Tomcat Developers List <[EMAIL PROTECTED]>
> Subject: Qn about a performance bottleneck in InvokerServlet
>
> The following code snippet is from the serveRequest() method of
> org.apache.catalina.servlets.InvokerServlet.java
>
> -----
>         String name = "org.apache.catalina.INVOKER." + servletClass;
>         String pattern = inServletPath + "/" + servletClass + "/*";
>         Wrapper wrapper = null;
>
>         // Synchronize to avoid race conditions when multiple requests
>         // try to initialize the same servlet at the same time
>         synchronized (this) {
>
>             // Are we referencing an existing servlet class or name?
>             wrapper = (Wrapper) context.findChild(servletClass);
>             if (wrapper == null)
>                 wrapper = (Wrapper) context.findChild(name);
>             if (wrapper != null) {
>                 if (debug >= 1)
>                     log("Using wrapper for servlet '" +
>                         wrapper.getName() + "' with mapping '" +
>                         pattern + "'");
>                 context.addServletMapping(pattern, wrapper.getName());
>              }
>
>             // No, create a new wrapper for the specified servlet class
>             else {
> -----
>
> What is the purpose of adding a servlet mapping of /servlet/$SERVLET/*
> for servlets serviced by the invoker ?
>

The purpose is a performance optimization -- on subsequent requests to
"/servlet/foo", the container should find an existing mapping for the
servlet, so it will get called directly instead of going through the
invoker.

> context.addServletMapping is called on every request to the
> InvokerServlet and shows up on performance profiles. Removing it did not
> affect the behaviour of InvokerServlet but it eliminated this
> performance hotspot.
>

The intent is that the invoker only gets called once for any given
"/servlet/xxx" pattern.  If it's actually executing the invoker again,
that's a bug (probably in the way the dynamically registered servlet
mapping's URL pattern is constructed).

> Thanks,
>  Arvind
>

Craig


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to