views:

28

answers:

1

Hi

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.

  1. 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)?
  2. "in some cases" - which cases are these? What are the situations where the performance is worse?
  3. Does this speed up the generation of the .java, the compilation of the .class or the execution of the .class?
  4. 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

A: 

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:

  1. A char[] has less memory overhead than String.
  2. The toCharArray() doesn't need to be (implicitly) called on every out.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.

BalusC