[concurrency-interest] Lock performance in virtualized environment

Talip Ozturk oztalip at gmail.com
Fri Feb 24 10:36:02 EST 2012


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:

Is this a known issue? Any way to optimize it?


More information about the Concurrency-interest mailing list