I'm not sure if any of this is helpful as I'm on a different platform and I'm not at all sure that anything I'm seeing will be applicable. When I run this version of your code here:

#! perl -sw use 5.010; use strict; use threads; $_->join for map { async { for( 1 .. 7e6 ) { int rand 10; } }; } 1 .. 64; say "Test 1 complete"; <STDIN>; $_->join for map { async { my $tmp; for ( 1 .. 7e6 ) { for ( 1 .. 1e5 ) { $tmp = $_; } int rand 10; } }; } 1 .. 64;

I do perceive a very slight drop in cpu sctivity between the first batch and the second.

The first nails the cpu counter at (or very close to) 75% (100% of 3 of 4 cpus--I have something running on the other cpu). What minor wobbles occur go no lower than 74.8; and it occasionally shows slightly greater than 75%--though that probably just the result of maths.

The second again gets close to 75%, but the wobbles are larger. It occasionally drops as far as 73% and rarely get as high as 74.8%. So something is preventing the second from maxing the cpu. I do not see any signs of locks, though I may not be instrumenting the right things. I need to look further into the measurements available--the list is very long. But in any case, the drop is nothing like as dramatic here, as your instrumentation appears to show on your platform!

Following anonymonks lead, I replaced (both) implicit loop counters with lexicals in the second batch:

for my $i ( 1 .. 7e6 ) { for my $j ( 1 .. 1e5 ) { $tmp = $j; }

And the drop in cpu utilization "went away", which does tend to indicate that it is somehow related to use of the global $_. Whilst that is global, it isn't shared, (I bleieve it is cloned on a per interpreter basis), so it shouldn't require internal locking. But globals do carry a small penalty over lexicals--regardless of the use of threads--so whether that has anything to do with it I am unsure. I can't see why it would, but I have considerable difficulty follwing the internals in areas that relate to cloning.

I'll try too look into it in more detail, but that will take a while.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: Solaris + UltraSparc T2 + Threads: Avoid LCK's by BrowserUk
in thread Solaris + UltraSparc T2 + Threads: Avoid LCK's by gulden

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.