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.
Created attachment 29224 [details] Patch for Mark.java
Moving to enhancement since there is no bug here. Please provide a test case that demonstrates the performance improvement.
Created attachment 29242 [details] Patch for JspReader.java
Created attachment 29243 [details] Patch for Mark.java
Created attachment 29244 [details] Comparison test case for JspReader
Created attachment 29245 [details] OldJspReader.java renamed from original JspReader.java
Created attachment 29246 [details] OldMark.java renamed from the original Mark.java
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 on attachment 29244 [details] Comparison test case for JspReader Change mime type
Nice improvement. I'll take a closer look at the patch with a view to including it in the next release.
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.
Shall JspReadler be thread-safe? Why is the member sourceFiles java.util.Vector?
Yes, this is a good question. It was a Vector before this fix. Could we change the typeto ArrayList ?