Google Groups Home
Help | Sign in
Message from discussion Performance characteristics of mutable static primitives?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
John Wilson  
View profile
 More options Apr 2, 5:10 am
From: "John Wilson" <tugwil...@gmail.com>
Date: Wed, 2 Apr 2008 10:10:52 +0100
Local: Wed, Apr 2 2008 5:10 am
Subject: Re: [jvm-l] Performance characteristics of mutable static primitives?
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
>  normal thread scaling), was an increment, mask, and test of a static int
>  field. The code in question looked like this:

>  private static int count = 0;

>  public void pollEvents(ThreadContext context) {
>    if ((count++ & 0xFF) == 0) context.poll();
>  }

>  So the basic idea was that this would call poll() every 256 hits,
>  incrementing a counter all the while. My first attempt to improve
>  performance was to comment out the body of poll() in case it was causing
>  a threading bottleneck (it does some locking and such), but that had no
>  effect. Then, as a total shot in the dark, I commented out the entire
>  line above. Thread scaling went to normal.

That is rather odd.

Shouldn't count be volatile?

If it's declared as volatile does that make any difference?

John Wilson


    Reply to author    Forward  
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.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google