tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David kerber <>
Subject Re: Performance with many small requests
Date Tue, 12 May 2009 16:03:32 GMT
Caldarale, Charles R wrote:
>> From: Leon Rosenberg []
>> Subject: Re: Performance with many small requests
>> If you would share your test code, I would love to test it on
>> some *nixes and darwins I have here;
> Here's the code I used to do the synch vs atomic testing.  The command line parameter
is the number of loops to perform; you'll want to set it to at least 1000000000, and even
then run repeated tests - the timings can vary considerably, at least under Vista.
> (Also being sent directly to the two requesters, in case the list strips the attachment.)
> Might be interesting to modify it to run with more cores, if you have a system available.
>  - Chuck
My dev machine:  WinXP SP3, dual-core 2.8GHz processor, java 1.5.0_12.

First, I ran it in Eclipse as supplied, with looplimit = 10000000, and got:

secondary atomic time: 6890; ticks: 51773402
primary atomic time: 6890; ticks: 48226599
secondary synchronized time: 21281; ticks: 50282172
primary synchronized time: 21281; ticks: 49717829

Then I reversed the order of the tests (just to be sure it didn't 
matter) and got similar results:

secondary synchronized time: 21219; ticks: 49601191
primary synchronized time: 21234; ticks: 50398810
secondary atomic time: 6734; ticks: 52111089
primary atomic time: 6734; ticks: 47888912

Running at a command line (java -cp . TestSynch) gave me rather 
different results (qualitatively similar, quantitatively rather different):

primary synchronized time: 42998; ticks: 59125831
secondary synchronized time: 42998; ticks: 40874170
secondary atomic time: 4953; ticks: 49025722
primary atomic time: 4953; ticks: 50974279

After several tests, the ratio between the synchronized and atomic times 
varied between about 5 and 9, but atomic was always the lower time.  
Running two instances simultaneously didn't change the numbers much (as 
expected from a dual-core machine), but the command window with the 
focus always ran significantly faster than the one without it, no matter 
which one was started first.

One very surprising result (to me, anyway) was that 4 instances only 
extended the time numbers slightly (<10%) for the synchronized run, and 
even less for the atomic run.  Going to 8 instances made a dramatic 
increase in the synchronized time, but again only a slight increase in 
the atomic version.  16 instances was too much for my system; it took a 
long time to start the last 8 or so, and both the atomic and the 
synchronized versions took a lot longer.

 From these tests, it looks like, under windows XP and java 1.5 any way, 
that atomics are always faster, and also handle increasing concurrency 
much better than synchronize() blocks do.

Now to test on my server!!


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message