tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Kientzle <kient...@acm.org>
Subject SimpleDateFormat considered harmful
Date Fri, 13 Oct 2000 19:43:43 GMT
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
Mime
View raw message