From: Charles Oliver Nutter <charles.nut...@sun.com>
Date: Wed, 02 Apr 2008 10:43:46 +0100
Local: Wed, Apr 2 2008 5:43 am
Subject: Re: [jvm-l] Re: Performance characteristics of mutable static primitives?
John Wilson wrote: I had not tried it because I expected volatile would only make it > On 4/2/08, Charles Oliver Nutter <charles.nut...@sun.com> wrote: >> I ran into a very strange effect when some Sun folks tried to benchmark >> JRuby's multi-thread scalability. In short, adding more threads actually >> caused the benchmarks to take longer. >> The source of the problem (at least the source that, when fixed, allowed >> private static int count = 0; >> public void pollEvents(ThreadContext context) { >> So the basic idea was that this would call poll() every 256 hits, > That is rather odd. > Shouldn't count be volatile? > If it's declared as volatile does that make any difference? slower. And in this case, the code in question didn't really care about perfect accuracy for the counter since it's just a rough guide. But here's numbers with volatile on my machine: Apple Java 5: ~/NetBeansProjects/jruby ➔ java -server Trouble 1 soylatte Java 6: ~/NetBeansProjects/jruby ➔ java -server Trouble 1 So as expected, volatile does slow things down a lot, but Java 6 does do I tried another non-volatile run using i += 1 rather than i++ and the Here's another set of numbers from Vladimir Sizikov, on a dual-core D:\work>D:/re/java5/bin/java -server Trouble 2 D:\work>D:/re/java6/bin/java -server Trouble 2 Again, significantly worse performance in Java 6 with multiple threads. - Charlie You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||