Bug 56614 - Add a switch to ignore annotations detection on tag instances for performance reason
Summary: Add a switch to ignore annotations detection on tag instances for performance...
Status: NEW
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 8.5.x-trunk
Hardware: All All
: P2 enhancement with 2 votes (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2014-06-12 09:02 UTC by Sheldon Shao
Modified: 2021-05-05 11:34 UTC (History)
0 users

Performance issue (255.62 KB, image/png)
2014-06-12 09:02 UTC, Sheldon Shao
Performance comparison between base and after patched (192.34 KB, image/png)
2014-06-12 09:03 UTC, Sheldon Shao
Patch (4.45 KB, patch)
2014-06-12 09:03 UTC, Sheldon Shao
Details | Diff
Document for this issue (375 bytes, text/plain)
2014-09-18 08:38 UTC, hzhang9

Note You need to log in before you can comment on or make changes to this bug.
Description Sheldon Shao 2014-06-12 09:02:24 UTC
Created attachment 31708 [details]
Performance issue

TagHandler instances are created in each jsp request.
If there are many tags in a jsp, it is very expensive to detect annotations for each instance's construction,
even DefaultInstanceManager has the annotation caches.

For almost all the tags, annotations shouldn't be presented.
So we need to provide a way to disable the annotation detection on tags.
Comment 1 Sheldon Shao 2014-06-12 09:03:24 UTC
Created attachment 31709 [details]
Performance comparison between base and after patched
Comment 2 Sheldon Shao 2014-06-12 09:03:57 UTC
Created attachment 31710 [details]
Comment 3 Manoj 2014-08-07 11:37:22 UTC
Is this patch included in any of the tomcat build?
Comment 4 Mark Thomas 2014-08-13 20:19:52 UTC
Restore this back to an enhancement
Comment 5 Mark Thomas 2014-08-18 15:13:02 UTC
Are these performance figures obtained with tag handler pooling enabled or disabled? If disabled, why was pooling disabled?
Comment 6 Mark Thomas 2014-08-18 15:19:32 UTC
Does the (apparrently undocumented) Context attribute ignoreAnnotations help? That disables annotation scanning for @PreDestroy and @PostConstruct for all components - not just tag handlers.
Comment 7 Mark Thomas 2014-08-18 15:21:00 UTC
If the patch is applied then a few changes will be required:
- config option needs to be documented
- new option doesn't just disabled @PreDestroy and @PostConstruct, it disables ot for JSPs as well
- a few renames are in order to reflect the previous point
Comment 8 hzhang9 2014-09-18 08:38:42 UTC
Created attachment 32032 [details]
Document for this issue
Comment 9 hzhang9 2014-09-18 08:46:53 UTC
I just find that a "SimpleInstanceManager" has been integrated on the TRUNK. It seems that it has solved the problem. Would you please back-port it to 7.0.x?
Comment 10 Manoj 2014-12-31 08:14:42 UTC
Can we have the fix backported to 7.0.x?
Comment 11 Dan Armstrong 2016-09-24 04:22:27 UTC
I have submitted a fix to this issue via a pull request on the github copy of the source for both Tomcat 7 and Tomcat 8.  Please merged these into the main Tomcat source repositories.

Lock contention alleviated via concurrent maps, while still maintaining the necessary weak keys.



Please also check if the Tomcat 9 in development has the same implementation based on WeakHashMap.  It is a serious point of lock contention under heavy concurrency.
Comment 12 Mark Thomas 2021-05-05 11:34:58 UTC
With Tomcat 7 reaching EOL, move the remaining open enhancement requests to
Tomcat 8.