You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Erik Hatcher <er...@ehatchersolutions.com> on 2004/11/02 10:08:06 UTC

Re: tips for improving performance

On Nov 2, 2004, at 2:21 AM, sebong oh wrote:
> I'v been studing Tapestry code.
> and i tested tapestry framework several times by using profiler.
> after testing, i found a few performance tips.

Excellent!

> 1. don't use private-asset except script.
>
>     private-asset uses ClasspathResourceLocation class to find proper 
> resource.
>     you know, class loader's getResource method first propagates the 
> request to their parent class loader to find resource.
>     if parent doesn't have that resource, and find it in itself.
>     this means getResource method call at worst, will open all 
> libraries (zip, jar). opening the zip file takes too much time.

Classloaders cache though, don't they?  Is this a one-time hit or does 
it occur for every request for a private asset?

>     so, instead use context-asset.

Another benefit to context-asset is that it can be externalized.

> 2. preparse all specifications and templates
>
>     component specification is also resource. so, it has a 
> private-asset like curse.
>     how to preparse it?
>
>     I modified tapestry source code to serialize all specification 
> classes.
>     fortunately, component specification related classes can be 
> serialized
>
>     and by using DefaultSpecificationSource class   you can easily 
> make specification preparser.
>
>     for template parsing use TemplateParser class

wow.  Impressive work.

> 3. Enhance Component classes  in advance.
>     Tapestry Class Enhancedment is a big feature comparing to other 
> framework. but enhancedment takes place in runtime.
>     it also consumes little time.
>
>     you can precomplile by using DefaultComponentClassEnhancer. 
> precompile it and packaging it with other classes.
>     and you must make new CompoentClassEnhancer to use precompiled 
> componet class. and override BaseEngine's createComponentClassEnhancer 
> method.
>
> i'm not native speaker,  but i think you can understand my optinions.

Very clear and understandable.

What kind of performance gains did you realize with your changes?

	Erik


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


Re: tips for improving performance

Posted by Howard Lewis Ship <hl...@gmail.com>.
Tapestry could do a bit more along these lines, but
ServletContext.getResourcePath() is part of the Servlet 2.3 or 2.4
API.


On Wed, 3 Nov 2004 16:36:37 -0500, Bryan Lewis <br...@maine.rr.com> wrote:
> There was a posting by Eric R. Glass on 7/1/2004 about preloading pages that
> struck me as quite handy for avoiding the first-time slowness, and for
> finding syntax errors early.  He used
> getApplicationSpecification().getPageNames() to find the page names.  The
> catch, as you say, is that all the pages need not be declared in the
> application specification.  However, it is possible to find them with a bit
> of plumbing code.  Here's what I've been using in my Engine class:
> 
> private void preloadPages(IRequestCycle cycle)
> {
>     // Ask the servlet API for all the resources under WEB-INF,
>     // which is where we put all our .page files.
>     String prefix = "/WEB-INF/";
>     String suffix = ".page";
> 
>     try {
>         Set set = cycle.getRequestContext().getServlet()
>                        .getServletConfig().getServletContext()
>                        .getResourcePaths(prefix);
>         Iterator it = set.iterator();
>         while (it.hasNext()) {
>             String name = (String) it.next();
>             if (name.endsWith(suffix)) {
>                 name = name.substring(prefix.length());
>                 name = name.substring(0, name.length() - suffix.length());
> 
>                 // Load the page.
>                 cycle.getPage(name);
>             }
>         }
>     }
>     catch (Exception e) {
>         // Syntax error or other loading problem?
>         // Log the complete trace.
>         reportException("!! Page preloading got exception: ", e);
>         // Make sure we see that a page-loading error happened.
>         throw new ApplicationRuntimeException(e);
>     }
> }
> 
> protected Object createVisit(IRequestCycle cycle)
> {
>     // ....
>     if (<this is the first time for this app>) {
>         preloadPages(cycle);
> 
> 
>     }
> }
> 
> ----- Original Message -----
> From: "Marcus Brito" <mb...@gmail.com>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Wednesday, November 03, 2004 6:26 AM
> Subject: Re: tips for improving performance
> 
> > Except for the "don't use private assets" tip, looks like your
> > enhancemens will greatly speed up the first time a page is accessed,
> > but won't help later. Classloaders already cache resources; Tapestry
> > already caches specifications, templates and enhanced classes.
> >
> > Nonetheless, there is value in this initial speed up -- maybe we can
> > hope to see a -Dorg.apache.tapestry.precompile=true option in Tapestry
> > 3.1 that will preparse templates, pre-enhance classes and the other
> > tips you mentioned, at application the application startup?
> >
> > There's only one gotcha: a tapestry application may not know in
> > advance all it's pages, since it's not mandatory to declare all your
> > pages in your application specification. However, at least the
> > declared pages could be preparsed/precompiled.
> >
> > Regarding OGNL, it's execution speed is a known issue: it's not the
> > fasted library on the planet. It's been said, however, that the soon
> > to be released OGNL 3.0 is greatly optimized for speed.I don't think
> > component pooling will help here: pages themselves are already pooled,
> > together will all components they contain.
> >
> > -- Marcus Brito <mb...@gmail.com>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com

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


Re: tips for improving performance

Posted by Bryan Lewis <br...@maine.rr.com>.
There was a posting by Eric R. Glass on 7/1/2004 about preloading pages that
struck me as quite handy for avoiding the first-time slowness, and for
finding syntax errors early.  He used
getApplicationSpecification().getPageNames() to find the page names.  The
catch, as you say, is that all the pages need not be declared in the
application specification.  However, it is possible to find them with a bit
of plumbing code.  Here's what I've been using in my Engine class:

private void preloadPages(IRequestCycle cycle)
{
    // Ask the servlet API for all the resources under WEB-INF,
    // which is where we put all our .page files.
    String prefix = "/WEB-INF/";
    String suffix = ".page";

    try {
        Set set = cycle.getRequestContext().getServlet()
                       .getServletConfig().getServletContext()
                       .getResourcePaths(prefix);
        Iterator it = set.iterator();
        while (it.hasNext()) {
            String name = (String) it.next();
            if (name.endsWith(suffix)) {
                name = name.substring(prefix.length());
                name = name.substring(0, name.length() - suffix.length());

                // Load the page.
                cycle.getPage(name);
            }
        }
    }
    catch (Exception e) {
        // Syntax error or other loading problem?
        // Log the complete trace.
        reportException("!! Page preloading got exception: ", e);
        // Make sure we see that a page-loading error happened.
        throw new ApplicationRuntimeException(e);
    }
}

protected Object createVisit(IRequestCycle cycle)
{
    // ....
    if (<this is the first time for this app>) {
        preloadPages(cycle);
    }
}


----- Original Message ----- 
From: "Marcus Brito" <mb...@gmail.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Wednesday, November 03, 2004 6:26 AM
Subject: Re: tips for improving performance


> Except for the "don't use private assets" tip, looks like your
> enhancemens will greatly speed up the first time a page is accessed,
> but won't help later. Classloaders already cache resources; Tapestry
> already caches specifications, templates and enhanced classes.
>
> Nonetheless, there is value in this initial speed up -- maybe we can
> hope to see a -Dorg.apache.tapestry.precompile=true option in Tapestry
> 3.1 that will preparse templates, pre-enhance classes and the other
> tips you mentioned, at application the application startup?
>
> There's only one gotcha: a tapestry application may not know in
> advance all it's pages, since it's not mandatory to declare all your
> pages in your application specification. However, at least the
> declared pages could be preparsed/precompiled.
>
> Regarding OGNL, it's execution speed is a known issue: it's not the
> fasted library on the planet. It's been said, however, that the soon
> to be released OGNL 3.0 is greatly optimized for speed.I don't think
> component pooling will help here: pages themselves are already pooled,
> together will all components they contain.
>
> -- Marcus Brito <mb...@gmail.com>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


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


Re: tips for improving performance

Posted by Marcus Brito <mb...@gmail.com>.
Except for the "don't use private assets" tip, looks like your
enhancemens will greatly speed up the first time a page is accessed,
but won't help later. Classloaders already cache resources; Tapestry
already caches specifications, templates and enhanced classes.

Nonetheless, there is value in this initial speed up -- maybe we can
hope to see a -Dorg.apache.tapestry.precompile=true option in Tapestry
3.1 that will preparse templates, pre-enhance classes and the other
tips you mentioned, at application the application startup?

There's only one gotcha: a tapestry application may not know in
advance all it's pages, since it's not mandatory to declare all your
pages in your application specification. However, at least the
declared pages could be preparsed/precompiled.

Regarding OGNL, it's execution speed is a known issue: it's not the
fasted library on the planet. It's been said, however, that the soon
to be released OGNL 3.0 is greatly optimized for speed.I don't think
component pooling will help here: pages themselves are already pooled,
together will all components they contain.

-- Marcus Brito <mb...@gmail.com>

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