tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Chaffee <>
Subject Re: SimpleDateFormat considered harmful
Date Tue, 17 Oct 2000 01:00:43 GMT
I haven't looked at your code, but can you try replacing
SimpleDateFormat with org.apache.tomcat.util.FastDateFormat in the
offending class and rerun the performance test?  It calls a
SimpleDateFormat, but caches its response, so it's only called once
per second.

Perhaps rewriting FastDateFormat to use your code would give us the
best of both worlds.  The reason to do this is that FastDateFormat is
used in other code, specifically logging, that is invoked very

Cheers -

 - Alex

On Fri, Oct 13, 2000 at 12:43:43PM -0700, Tim Kientzle wrote:
> While stress-testing a Tomcat-based servlet system,
> I'm running into performance problems caused
> by thread contention.  Most of them have been
> in my code, but I just found a big one within Tomcat:
> org.apache.tomcat.util.MimeHeaderField.dateFormat()
> invokes a java.text.SimpleDateFormat object to format
> the dates on outgoing headers.  SimpleDateFormat relies
> on DecimalFormat, which is synchronized.  (With 50
> simultaneous requests against my servlet, I'm seeing over 20
> of them waiting on a single shared DecimalFormat object.)
> The attached sample program contains a drop-in replacement
> for MimeHeaderField.dateFormat() that produces exactly the
> same results, but is approximately six times faster and is
> not synchronized.  Please include this (or something similar)
> in Tomcat to improve performance.
> Just for the record: the attached program is my own work,
> I release it into the public domain.  Do with it as you will.
> 			- Tim Kientzle

Alex Chaffee             
jGuru - Java News and FAQs
Creator of Gamelan       
Founder of Purple Technology
Curator of Stinky Art Collective

View raw message