I am looking into the options available to me for optimising the performance of JBoss 5.1.0.
One of the options I am looking at is setting genStrAsCharArray
to true
in <JBOSS_HOME>/server/<PROFILE>/deployers/jbossweb.deployer/web.xml
. This affects the generation of .java code from .JSPs.
The comment describes this flag as:
Should text strings be generated as char arrays, to improve performance in some cases?
I have a few questions about this.
- Is this the generation of Strings in the dynamic parts of the JSP page (ie each time the page is called) or is it the generation of Strings in the static parts (ie when the .java is built from the JSP)?
- "in some cases" - which cases are these? What are the situations where the performance is worse?
- Does this speed up the generation of the .java, the c开发者_JS百科ompilation of the .class or the execution of the .class?
- At a more technical level (and the answer to this will probably depend on the answer to part 1), why can the use of char arrays improve performance?
Thanks in advance
Rich
With this setting all String
values are declared as static char[]
as follows:
static char[] _char_array_1 = "someString".toCharArray();
and used as follows:
out.write(_char_array_1);
instead of being used as follows:
out.write("someString");
This has two clear benefits:
- A
char[]
has less memory overhead thanString
. - The
toCharArray()
doesn't need to be (implicitly) called on everyout.write(string)
anymore.
Sounds like microoptimization, but those little bits counts a lot in a heavily visited website.
This setting is by the way not JBoss AS specific. It's Jasper specific, the JSP compiler of Apache Tomcat which is also used in under each JBoss AS and Sun Glassfish.
精彩评论