Return-Path: Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 47711 invoked from network); 17 Oct 2000 01:16:41 -0000 Received: from karen3.immaculate.org (HELO edamame.stinky.com) (209.60.53.27) by locus.apache.org with SMTP; 17 Oct 2000 01:16:41 -0000 Received: (qmail 32276 invoked by uid 510); 17 Oct 2000 01:00:44 -0000 Date: Mon, 16 Oct 2000 18:00:43 -0700 From: Alex Chaffee To: tomcat-dev@jakarta.apache.org, kientzle@acm.org Subject: Re: SimpleDateFormat considered harmful Message-ID: <20001016180043.D30914@edamame.stinky.com> Reply-To: alex@jguru.com References: <39E765EF.25845C45@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <39E765EF.25845C45@acm.org>; from kientzle@acm.org on Fri, Oct 13, 2000 at 12:43:43PM -0700 X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N 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 frequently. 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 mailto:alex@jguru.com jGuru - Java News and FAQs http://www.jguru.com/alex/ Creator of Gamelan http://www.gamelan.com/ Founder of Purple Technology http://www.purpletech.com/ Curator of Stinky Art Collective http://www.stinky.com/