users@glassfish.java.net

Re: Compiling JSP is slow on v3

From: <glassfish_at_javadesktop.org>
Date: Mon, 06 Sep 2010 04:50:59 PDT

> The "Generated" times are the times spent in
> compiling the JSP files to Java files, while the
> "Compiled" times are those spent in javac, comiling
> Java files to class files. There are a couple of
> things to remember when looking at the numbers.
>
> 1. The first "Compiled" time is always big, since it
> takes time to startup javac. Subsequent javac
> compilations should be much faster. Try redeploy your
> app again, and see the numbers go down.
>
> 2. The "Generated" time for a jsp file actually
> includes the time it takes (Generated and Compiled)
> to compile all the dependent tag files. That why the
> generated time for login.jsp and home.jsp is large,
> probably because they reference tag files which may
> in term reference other tag files.

Ok, thanks for the explanation!

> I have done some measurements on the compilation
> times on v2 and v3. My test case is a simple jsp
> files that reference another simple tag files:
>
> bra.jsp:
> <%@ taglib prefix="test" tagdir="/WEB-INF/tags" %>
> begin
> <test:brack>
> <test:brack>
> qwertyui
> </test:brack>
> </test:brack>
> d
>
> brack.tag
> [== <jsp:doBody/> ==]
>
> I got the following times:
>
> | v2 initial | v2
> redeploy | v3 initial | v3 redeploy |
> G time brack.tag | 15 |
> 1 | 18 |
> 1 |
> 759 | 86 | 1337 |
> 159 |
> | 895 | 94 | 1771
> | 176 |
> C time bra.jsp | 83 |
> 75 | 171 | 161
> |
>
> Several things are obvious:
>
> 1. G time for bra.jsp is greater than G and C times
> for brack.tag because the times in brack.tag are
> included.

Right.

> 2. The times after redeploy are much less than the
> initial time.

I don't understand this, and don't know how to reproduce it. Redeploy?? For me, that's building a new WAR file and copying it to .../domain1/autodeploy. And then I get the same (long) times for Generated and Compiled. (At least it's reproducible... :-) )

> 3. V3 times are larger than V2 times, like you all
> said. But not as bad as I was led to believe. I can
> probably explain why javac take more time in V3: it
> has now more jar files in javac classpath. There are
> now over 250 of them!

Could be a clue, yes. I wouldn't be surprised if there are several factors, all adding to the extra time.

> I'll certainly look into this more, to see where why
> JSP compilation is slower in V3. It would great if
> you can give your test case. It doesn't have to run,
> just needs to able to compile. Thanks.

I'll try to make a small test case, more similar to what my application is doing. Btw, I use PRG, so all requests first go to my main controller servlet (and massaged using EJBs) and then later redirected to a resulting Wiew JSP.

Meanwhile, I took your test case, renamed it to foo.jsp and foo.tag, and ran it in my app. First I logged in and got to the main.jsp, then entered foo.jsp directly in the URL (so no PRG there). Results below. I do all measurements twice, to see any spurious variations. I don't understand how to do the 'redeploy' test case, please explain.

Today, I also stumbled on another problem; exec("bar.exe") from a servlet causes a security exception. It turns out that v2 has the Security Manager off by default, and v3 has it on by default. Sneaky! So I turned the Security Manager off using the Admin Console, and suddenly my measurements produced different, lower, numbers. So that could be yet another factor!

 v3 initial | v3 initial with Security Manager

G time foo.tag | 0 0 | 0 0
C time foo.tag | 953 987 | 1766 1735

G time foo.jsp | 984 1016 | 1828 1812
C time foo.jsp | 891 937 | 1719 1641

One thing that's immediately notable is that our times for "v3 initial" C time foo.jsp is widely different.

What do you think?
[Message sent by forum member 'tmpsa']

http://forums.java.net/jive/thread.jspa?messageID=481963