Bug 53713 - Performance tuning solution for JspReader
Performance tuning solution for JspReader
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Jasper
trunk
All All
: P2 enhancement (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-08-14 06:28 UTC by Sheldon Shao
Modified: 2012-10-29 06:27 UTC (History)
0 users



Attachments
patch for JspReader.java (5.35 KB, patch)
2012-08-14 06:28 UTC, Sheldon Shao
Details | Diff
Patch for Mark.java (1.36 KB, patch)
2012-08-14 06:29 UTC, Sheldon Shao
Details | Diff
Patch for JspReader.java (8.11 KB, patch)
2012-08-17 14:29 UTC, Sheldon Shao
Details | Diff
Patch for Mark.java (1.85 KB, patch)
2012-08-17 14:30 UTC, Sheldon Shao
Details | Diff
Comparison test case for JspReader (6.12 KB, text/plain)
2012-08-17 14:31 UTC, Sheldon Shao
Details
OldJspReader.java renamed from original JspReader.java (18.48 KB, application/octet-stream)
2012-08-17 14:32 UTC, Sheldon Shao
Details
OldMark.java renamed from the original Mark.java (7.33 KB, application/octet-stream)
2012-08-17 14:33 UTC, Sheldon Shao
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sheldon Shao 2012-08-14 06:28:58 UTC
Created attachment 29223 [details]
patch for JspReader.java

mark() is called so many times when doing JSP or tag files compilation.
This can be reduced by a little bit code changes.

Attached files contain this solution.
Comment 1 Sheldon Shao 2012-08-14 06:29:38 UTC
Created attachment 29224 [details]
Patch for Mark.java
Comment 2 Mark Thomas 2012-08-15 20:43:47 UTC
Moving to enhancement since there is no bug here.

Please provide a test case that demonstrates the performance improvement.
Comment 3 Sheldon Shao 2012-08-17 14:29:52 UTC
Created attachment 29242 [details]
Patch for JspReader.java
Comment 4 Sheldon Shao 2012-08-17 14:30:23 UTC
Created attachment 29243 [details]
Patch for Mark.java
Comment 5 Sheldon Shao 2012-08-17 14:31:30 UTC
Created attachment 29244 [details]
Comparison test case for JspReader
Comment 6 Sheldon Shao 2012-08-17 14:32:25 UTC
Created attachment 29245 [details]
OldJspReader.java renamed from original JspReader.java
Comment 7 Sheldon Shao 2012-08-17 14:33:04 UTC
Created attachment 29246 [details]
OldMark.java renamed from the original Mark.java
Comment 8 Sheldon Shao 2012-08-17 14:37:54 UTC
Test case for comparison,

Webapp test/webapp-2.3 New JspReader:529
Webapp test/webapp-2.3 Old JspReader:2256

Webapp test/webapp-2.4 New JspReader:362
Webapp test/webapp-2.4 Old JspReader:1392

Webapp test/webapp-2.5 New JspReader:441
Webapp test/webapp-2.5 Old JspReader:1338

Webapp test/webapp-3.0 New JspReader:9525
Webapp test/webapp-3.0 Old JspReader:26608

Webapp test/webapp-3.0-fragments New JspReader:1416
Webapp test/webapp-3.0-fragments Old JspReader:3417

Webapp test/webapp-3.0-servletsecurity2 New JspReader:406
Webapp test/webapp-3.0-servletsecurity2 Old JspReader:1011

Webapp test/webapp-3.0-virtual-webapp New JspReader:2495
Webapp test/webapp-3.0-virtual-webapp Old JspReader:4935
		

Here is part of the test case,

                 int count = 1000;
		long start = System.currentTimeMillis();
		for(int i = 0; i < count; i ++) {
			goThroughAllJsp(appDir, true);
		}
		System.out.println("Webapp " + folder + " New JspReader:"
				+ (System.currentTimeMillis() - start));
		start = System.currentTimeMillis();
		for(int i = 0; i < count; i ++) {
			goThroughAllJsp(appDir, false);
		}
		System.out.println("Webapp " + folder + " Old JspReader:"
				+ (System.currentTimeMillis() - start));
Comment 9 Mark Thomas 2012-09-03 15:05:42 UTC
Comment on attachment 29244 [details]
Comparison test case for JspReader

Change mime type
Comment 10 Mark Thomas 2012-09-05 16:42:23 UTC
Nice improvement. I'll take a closer look at the patch with a view to including it in the next release.
Comment 11 Mark Thomas 2012-09-05 22:15:15 UTC
Thanks for the patch. It has been applied (with slight formatting changes) to trunk and 7.0.x and will be included in 7.0.31 onwards.
Comment 12 Eugene Chung (TmaxSoft) 2012-10-29 05:27:47 UTC
Shall JspReadler be thread-safe? Why is the member sourceFiles java.util.Vector?
Comment 13 Sheldon Shao 2012-10-29 06:27:04 UTC
Yes, this is a good question.  It was a Vector before this fix.
Could we change the typeto ArrayList ?