[concurrency-interest] Lock performance in virtualized environment

Nathan Reynolds nathan.reynolds at oracle.com
Fri Feb 24 12:59:05 EST 2012


park()/unpark() and wait()/notify() both go into the kernel.  Inside the 
kernel, the scheduler logic has to send a software interrupt to another 
idling core to get it to wake up and start running the signaled thread.  
These interrupts are a lot more expensive in a virtualized environment.  
They can cause traps out to the hypervisor.  Check the system CPU time 
on both and see if in the virtualized environment it is higher.  If so, 
this might be on the right track.  There might be some tuning you can do 
with Parallels to get your test to perform better.  On the other hand, 
if all of the cores are 100% busy, then the software interrupt won't be 
necessary to wake up the idling core.

Nathan Reynolds 
<http://psr.us.oracle.com/wiki/index.php/User:Nathan_Reynolds> | 
Consulting Member of Technical Staff | 602.333.9091
Oracle PSR Engineering <http://psr.us.oracle.com/> | Server Technology

On 2/24/2012 9:42 AM, √iktor Ҡlang wrote:
>
> Use a non-blocking concurrent hashmap.
>
> Cheers
> V
>
> On Feb 24, 2012 4:42 PM, "Talip Ozturk" <oztalip at gmail.com 
> <mailto:oztalip at gmail.com>> wrote:
>
>     Hi,
>
>     I did a simple test to see how virtualized environment affects the
>     performance of a multithreaded application. My test application was
>     creating a ConcurrentHashMap, starting 40 threads, each doing
>     map.put() in a while(true) loop. I ran it on my laptop (MacBookAir i7)
>     first and then started a Ubuntu on Parallels with same number of CPUs.
>     I was happy to see that both my laptop and the Ubuntu on Parallels
>     were doing -almost- the same number of map.put() operations per sec.
>     So virtualization wasn't affecting much.
>
>     Then I changed my ConcurrentHashMap to have concurrencyLevel=1 to see
>     how contention will affect. Performance went down on each as expected
>     but throughput of virtual machine was half of my laptop!
>
>     I then started playing with LockSupport.park/unpark. The results were
>     similar: Throughput is half on virtualized environment. I am getting
>     the same feeling when running my tests on Amazon EC2. Looks like
>     others had the same issue:
>     https://forums.aws.amazon.com/thread.jspa?threadID=75388
>
>     Is this a known issue? Any way to optimize it?
>
>     Thanks,
>     -talip
>     _______________________________________________
>     Concurrency-interest mailing list
>     Concurrency-interest at cs.oswego.edu
>     <mailto:Concurrency-interest at cs.oswego.edu>
>     http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120224/84dd27ca/attachment.html>


More information about the Concurrency-interest mailing list