Prepend
2005-03-08
  StringBuffer/StringWriter slowdown
So I've been travelling a bit. San Francisco last week and this week in Denver. Getting a tour of various hotels and airlines.

So, in pre jdk1.5 the StringBuffer class is one of the most widely used classes. Especially in Servlets and JSPs, this class is used everywhere. The problem is that it is thread-safe. This might be good for some people, but it is terrible for web performance. With Request/Response, buffers are never shared between threads so all that synchronization is wasted.

I looked around and couldn't find any open source non-synchronized StringBuffers and my projects can't run on jdk1.5 yet (to take advantage of FastStringBuilder) so I had to write a new non-thread safe/non-synchronized FastStringBuffer class. I also wrote a new FastStringWriter class to replace java.io.StringWriter that uses FastStringBuffer instead of StringBuffer.

So anyway, I need to clean up the class and submit it to jakarta commons lang or something. But it is a decent performance boost (about 50-200ms per page) that may help out your project.
 
Comments:
This post has been removed by the author.
 
Post a Comment



<< Home
Technical and personal notes from Brian Lee, technologist/enterprise architect/software developer/soa guy.

ARCHIVES
February 2005 / March 2005 / April 2005 / May 2005 / June 2005 / July 2005 / August 2005 / September 2005 / October 2005 / November 2005 / December 2005 / January 2006 / February 2006 / March 2006 / April 2006 / May 2006 / June 2006 / August 2006 / September 2006 / October 2006 / November 2006 / December 2006 / January 2007 / May 2007 / June 2007 / August 2007 / September 2007 / October 2007 / April 2008 / July 2008 / January 2009 / May 2009 / June 2009 /
My Photo
Name: Brian Lee
Location: Atlanta, Georgia, United States

 
Web prepend.com






Powered by Blogger