Hi,

Here's a slightly reduced example, with most important tings in just
two lines, one marked SLOW and another marked FAST.

http://pastie.org/174059

// if ((i++ & 0xFF) == 0) firedCount++; // SLOW
// if ((i++ & 0xFF) == 0) Counter.firedCount++; // FAST

The difference in timings on my Dual-Core Core2Duo CPU on JDK 6u5 is about 2x!
And the only difference in code is where the static counter lives:
either on main class (then it slow) or in static member class (then
it's 2x faster!)

The test was executed with 2 threads and with -server switch:
D:/re/java6/bin/java -server Trouble 2

JDK 5 and JDK 1.4 behave as expected and there is no significant difference.

Thanks,
  --Vladimir

On Wed, Apr 2, 2008 at 5:51 PM, Charles Oliver Nutter
<[EMAIL PROTECTED]> wrote:
>
>  Jochen Theodorou wrote:
>  > I think there is not enough data to see a trend. I modified your test,
>  > made it run from 1-20 threads and for 50 loops, making an average time
>  > containing the time it took to execute all threads and put these in a
>  > diagram. I used a Q6600 Quadcore intel CPU with java 1.6.0_03-b05 on
>  > Linux 2.6.22-14-generic #1 SMP x86_64 GNU/Linux. What I can see is that
>  > the time constantly goes up until 4 Threads are reached, my number of
>  > CPUs. Using 5 threads is takes less time than using 4, but after that
>  > the time looks more or less constant.
>  >
>  > This looks quite scalable to me.
>
>  You did notice the code splits the number of iterations by the number of
>  threads, right? At the very least, the amount of time taken to run all
>  threads should go down.
>
>  Run the same test in Java 5 and you'll see that Java 6 does not scale
>  properly at all for this test.
>
>  - Charlie
>
>
>
>  >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to