[EMAIL PROTECTED] wrote:

remm        2004/10/18 16:16:36

Modified: util/java/org/apache/tomcat/util/buf CharChunk.java
ByteChunk.java
Added: util/java/org/apache/tomcat/util/buf StringCache.java
Log:
- Refactor toString for the buffers, and add a cache.
- The cache works in two phases:
- First phase is heavily synchronized, and keeps statistics on String usage
- When first phase is done (after a number of calls to toString), a cache array is generated; this might be a rather expensive operation
- During the second phase, unsynchronized lookups in the static cache are done to try to avoid expensive toString conversions
- If the cache is registered in JMX (later ...), an operation exists to get back to the beginning of the first phase. This could be useful
after installing new applications on the fly, which could have different Strign requirements.
- I think it works really well for ByteChunk -> String, since this is a quite expensive operation (note: some of these conversions could
be optimized by assuming US-ASCII encoding, which I'll do for the session ID cookie value since it's so commonly used - and the String
is not cacheable, obviously - but doing the trick everywhere would lead to major problems). For CharChunk, it's less evident, as
it is a matter of allocating a String, a char array and then using an arraycopy to move over the chars.
- This is configured using system properties, for example in the catalina.properties file. Byte and char can be enabled separately.


More optimizations:
- Optimize getting session id from the session id cookies: there might be more that one cookie, and all use straight byte -> String conversion (although they are conversion friendly US-ASCII encoded); this will also avoid keeping track of too much stuff in the byte cache
- Enable the cache for ByteChunk by default (so that it gets tested, and optimizing away some of these expensive conversions could be quite useful)


Rémy


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to