Patch: FYI: java.util.ResourceBundle

Bryce McKinlay mckinlay@redhat.com
Sat Jul 10 02:13:00 GMT 2004


This patch implements a new caching strategy for ResourceBundle and also 
simplifies the lookup code substantially.

The previous version used SoftReferences in its cache - unfortunately 
these are not fully implemented in libgcj and the references would be 
deleted during each GC cycle, resulting in poor lookup performance since 
the same ResourceBundles would be loaded over and over. I don't think 
using SoftReferences is a significant win here - although a resource 
bundle may contain many localized strings, I would imagine that the 
typical usage model is for those strings to stay in use throughout the 
lifetime of the application. Perhaps this decision could be revisted 
later, when we have a fully implemented SoftReference.

The old version also created a StringBuffer and did String manipulation 
in getBundle() even in the case where the bundle was cached. There is 
now no allocations or string manipulation required for getBundle() in 
the case where the bundle is found in the cache.

These improvements double libgcj's performance for the following test 
case, from ~35s to ~17s. This test case results in a lot of calls to 
Calendar.getInstance() which in turn uses ResourceBundle.getBundle().

I'm checking this in. I will also merge into classpath if nobody beats 
me to it.

Regards

Bryce


-------------- next part --------------
A non-text attachment was scrubbed...
Name: DateTester.java
Type: text/x-java
Size: 414 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040710/466d9375/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libgcj-resourcebundle.patch
Type: text/x-patch
Size: 16265 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040710/466d9375/attachment-0001.bin>


More information about the Java-patches mailing list