[concurrency-interest] Measuring lock contention with ThreadMXBean

Joseph Seigh jseigh_cp00 at xemaps.com
Thu Mar 29 22:06:44 EDT 2007


Jeremy Manson wrote:

>
> Joseph Seigh wrote:
>
>> The locks are whatever ThreadMXBean measures.   I suspect it is the 
>> GC which appears to be using
>> conventional synchronization to park threads.   
>
>
> I was going to respond with this -- I've seen contention happen in 
> ReferenceQueue.remove and enqueue regardless of what else you are 
> doing in your code.  It is possible to measure this using JVMTI.
>
>                     Jeremy
>
I'm not currently using ReferenceQueues explicitly so unless they're 
implicit with the use of some
reference types.

I added in a gc bean to the program output.  the xmem version is really 
churing through memory.

thread count = 20
loop count   = 5000

starting ConcurrentLinkedQueue ...
elapsed time   = 471 msec
total time     = 4760
system time    = 220
user time      = 190
blocked time   = 996
blocked count  = 30
waited time    = 0
waited count   = 0
gc name        = Copy
gc time        = 47
gc count       = 6
gc name        = MarkSweepCompact
gc time        = 16
gc count       = 1
sum           = 249950000 (expected 249950000)

starting LinkedBlockingQueue ...
elapsed time   = 321 msec
total time     = 1461
system time    = 100
user time      = 100
blocked time   = 0
blocked count  = 0
waited time    = 1318
waited count   = 21
gc name        = Copy
gc time        = 47
gc count       = 6
gc name        = MarkSweepCompact
gc time        = 16
gc count       = 1
sum           = 249950000 (expected 249950000)

starting Synchronized LinkedList ...
elapsed time   = 2343 msec
total time     = 42360
system time    = 2042
user time      = 861
blocked time   = 39478
blocked count  = 199553
waited time    = 0
waited count   = 0
gc name        = Copy
gc time        = 4
gc count       = 8
gc name        = MarkSweepCompact
gc time        = 16
gc count       = 1
sum           = 249950000 (expected 249950000)

starting XmemQueue ...
elapsed time   = 5959 msec
total time     = 84800
system time    = 1241
user time      = 1241
blocked time   = 70687
blocked count  = 1226
waited time    = 0
waited count   = 0
gc name        = Copy
gc time        = 4338
gc count       = 75
gc name        = MarkSweepCompact
gc time        = 35
gc count       = 1
sum           = 249950000 (expected 249950000)
tries    = 200224
retries  = 223
notries  = 220
noswaps  = 9
nodes    = 119551
nodes2   = 0



--
Joe Seigh


More information about the Concurrency-interest mailing list