Bug 48600 - Performance issue with tags
Summary: Performance issue with tags
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Servlet & JSP API (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 enhancement with 3 votes (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
URL:
Keywords: PatchAvailable
: 48750 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-01-22 04:59 UTC by adrien.futschik
Modified: 2012-06-12 14:04 UTC (History)
4 users (show)



Attachments
Patch to add cache in DefaultAnnotationProcessor (18.51 KB, patch)
2010-02-04 01:28 UTC, Philippe Prados
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description adrien.futschik 2010-01-22 04:59:36 UTC
When upgrading from Tomcat 5.5.x to Tomcat 6.0.x we are experiencing performance issues.

We are using the same exact application in both versions. The application uses JSP & tags.

Here is a quick list of the average loading time recorded (in ms) using Jmeter :

Tomcat 5.5.23 : 32
Tomcat 6.0.18 / 6.0.20 : 143

When positioning the metadata-complete="true" in the web.xml file the loading are much better :

Tomcat 6.0.18 / 6.0.20 : 34

How would you explain this ?

The metadata-complete="true" parameter is not a real solution for us because we would like to use annotations in the future.

Adrien
Comment 1 Mark Thomas 2010-02-01 16:43:18 UTC
I can't see anything that would impact per request. You are going to take a hit on the annotation scanning on first load. A profiler will tell you more.

This is really a topic more suited to the users list. Please follow up there.
Comment 2 Philippe Prados 2010-02-02 02:35:18 UTC
With Tomcat 6.0.x, when the metadata-complete is set to true, the AnnotationProcessor is empty, and all annotation like @Resources in tag are not managed.

I think the spec never say that.

The performance issues is due to the presence of AnnotationProcessor with a page with many tags. Because the implementation have not a cache, and manage all the super class (to class Object !), a big loop is present for each attributs, each methods, for each tag classes and super classes, before and after the tag.

We think it's may be better to add a cache to remember of classes with or without annotations.

Philippe
Comment 3 Mark Thomas 2010-02-02 03:18:55 UTC
Patches are always welcome
Comment 4 adrien.futschik 2010-02-02 09:01:02 UTC
(In reply to comment #3)
> Patches are always welcome

We are working on a patch based on TRUNK to implement a cache and are trying to test out DefaultAnnotationProcessor.java. Our solution improves performance drastically but we need to test it more deeply.

Do you have some unit-tests for this class ?

Adrien
Comment 5 Mark Thomas 2010-02-02 09:02:28 UTC
Very little I am afraid. All we have is in the test dir.
Comment 6 Philippe Prados 2010-02-04 01:28:14 UTC
Created attachment 24924 [details]
Patch to add cache in DefaultAnnotationProcessor

With some test case, this version is 6 times faster !

JBoss use a DummpAnnotationProcessor to remove this capabilities. I think, now, JBoss can use this new version.

Regards

Philippe Prados
Comment 7 Remy Maucherat 2010-02-16 13:00:02 UTC
*** Bug 48750 has been marked as a duplicate of this bug. ***
Comment 8 Remy Maucherat 2010-02-16 13:44:56 UTC
(In reply to comment #6)
> JBoss use a DummpAnnotationProcessor to remove this capabilities. I think, now,
> JBoss can use this new version.

Which version of JBoss AS are you talking about ? If it's branch 4.2, then it doesn't support EE 5, so it's not supposed to be doing injection. That makes things simpler obviously.

JBoss AS (for the releases that do injection) uses an implementation of Tomcat's instance manager (which may or may not perform better, as I didn't micro bench it).
Comment 9 Philippe Prados 2010-02-16 15:44:54 UTC
With JBoss 5.0.0 GA, the class 
org.apache.catalina.core.StandardContext.DummyAnnotationProcessor
implements an empty processor.
It's hard coding to use this "special" version.

Philippe Prados
Comment 10 Remy Maucherat 2010-02-18 17:40:37 UTC
(In reply to comment #9)
> With JBoss 5.0.0 GA, the class 
> org.apache.catalina.core.StandardContext.DummyAnnotationProcessor
> implements an empty processor.
> It's hard coding to use this "special" version.

Yes, but this "implementation" does nothing but delegate to the InstanceManager, which then does the same things as Tomcat's AnnotationProcessor (except slightly slower). For some background history, the AnnotationProcessor interface was replaced with the InstanceManager interface to also take over the object instance creation.

AS 5 scans injections ahead of time, so it does what your caching does more or less. The main problem here is that the newer JSP specs made tags non poolable in many cases, *and* injectable. Not a very good plan ...

BTW, your patch would need some syncs I think.
Comment 11 Philippe Prados 2010-03-08 11:03:45 UTC
Ok. It's correct with JBoss but no with Tomcat.
Comment 12 Philippe Prados 2010-05-07 11:11:28 UTC
Do you do something to optimize the code ?
Comment 13 Mark Thomas 2012-06-12 14:04:24 UTC
Caching has been added in the 7.0.x series but will not be back-ported to 6.0.x.