I've done some tests with the below code hope this helps David
10 Processor Sun Sparc 2i 400Mhz (Solaris 2.8) jdk 1.4.0-b92 time java TestDatePerf 1 10000 real 0m2.096s user 0m1.901s sys 0m0.142s time java TestDatePerf 2 10000 real 0m4.848s user 0m4.240s sys 0m1.372s time java TestDatePerf 3 10000 real 0m7.449s user 0m6.530s sys 0m3.312s time java TestDatePerf 4 10000 real 0m11.140s user 0m8.661s sys 0m4.543s time java TestDatePerf 5 10000 real 0m13.194s user 0m11.001s sys 0m7.182s time java TestDatePerf 6 10000 real 0m17.981s user 0m12.381s sys 0m8.602s time java TestDatePerf 7 10000 real 0m20.659s user 0m15.271s sys 0m10.102s time java TestDatePerf 8 10000 real 0m22.540s user 0m17.501s sys 0m13.603s time java TestDatePerf 9 10000 real 0m26.457s user 0m19.991s sys 0m14.793s time java TestDatePerf 10 10000 real 0m32.006s user 0m22.451s sys 0m15.923s time java TestDatePerf 20 10000 real 0m57.951s user 0m43.660s sys 0m37.772s time java TestDatePerf 30 10000 real 1m23.016s user 1m6.050s sys 0m56.952s time java TestDatePerf 40 10000 real 1m52.507s user 1m28.651s sys 1m15.832s time java TestDatePerf 50 10000 real 2m21.881s user 1m49.161s sys 1m35.772s linux dual 2.8Ghz P4 (kernel 2.4.19 ) jdk1.4.1_03-b02 time java TestDatePerf 1 10000 real 0m0.453s user 0m0.410s sys 0m0.020s time java TestDatePerf 2 10000 real 0m1.411s user 0m1.390s sys 0m0.410s time java TestDatePerf 3 10000 real 0m3.119s user 0m2.890s sys 0m1.610s time java TestDatePerf 4 10000 real 0m3.690s user 0m3.040s sys 0m1.780s time java TestDatePerf 5 10000 real 0m4.630s user 0m3.330s sys 0m2.360s time java TestDatePerf 6 10000 real 0m5.410s user 0m4.530s sys 0m2.480s time java TestDatePerf 7 10000 real 0m6.310s user 0m5.030s sys 0m3.000s time java TestDatePerf 8 10000 real 0m7.330s user 0m5.510s sys 0m3.590s time java TestDatePerf 9 10000 real 0m8.682s user 0m6.970s sys 0m4.060s time java TestDatePerf 10 10000 real 0m9.648s user 0m7.730s sys 0m4.760s time java TestDatePerf 20 10000 real 0m19.270s user 0m15.500s sys 0m9.210s time java TestDatePerf 30 10000 real 0m32.570s user 0m26.940s sys 0m14.740s time java TestDatePerf 40 10000 real 0m42.492s user 0m35.130s sys 0m20.560s time java TestDatePerf 50 10000 real 0m57.209s user 0m47.040s sys 0m25.330s David Rees <[EMAIL PROTECTED] To: Tomcat Developers List <[EMAIL PROTECTED]> .com> cc: Subject: Re: java Date related classes synchronization bottlenecks 11/07/2003 02:52 Please respond to "Tomcat Developers List" On Thu, Jul 10, 2003 at 05:46:06PM -0500, Glenn Nielsen wrote: > > Now use jar to unarchive the src.jar file in your java SDK. > Take a look at the java.sql.Timestamp.toString() method which the FileLogger > above uses. > > To verify this look at the source for java.util.Date.getField(). Yes, that looks bad (looking at 1.4.2 src)! It appears that avoiding calls to the Timestamp.toString() is really to be avoided if possible. > And there are many other synchronization bottlenecks in the following Date > related classes: > > java.util.Calendar.getInstance() > java.util.Date > java.util.TimeZone.getDefault() > java.sql.Date > java.sql.Time > java.sql.Timestamp I took a look at some of these, these don't appear to be as bad as the Timestamp.toString(). I did a quick google of Date performance issues and didn't find anything. Is this a well known bottleneck in multi-threaded applications? > > Does a simple test case which simply starts up a number of threads which > > all use one of the classes shown below display the problem nicely? > > I am sure it would, I haven't had time to write one up yet. I wrote a simple multithreaded program which makes calls to Timestamp.toString() and varied the number of threads running and the number of calls. On a single CPU system (a Duron 600), scaling from 1-20 threads performed as I expected, with the 20 thread iteration taking only slightly longer than the single thread iteration. However, when running this on a dual-cpu system (PIII 500), going from 1 to 2 treads took over twice as long for the same overall number of calls to Timestamp.toString(). From 4-20 threads overall time slightly increased most likely due to the overhead of scheduling multiple threads. You must be running on a multiple-CPU system as it doesn't appear to be a bottle-neck (except for the fact that it's a slow operation) on a single-cpu machine and only one multi-cpu machines. Given that this is the case, a temporary fix in your case would be to run as many Tomcat's as you have processors on that particular machine (assuming you have enough memory) -Dave --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The following file(s) have been deleted by: David Cassidy on 11/07/2003 09:55:57 TestDatePerf.java ATT1GXC9 -- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]