Read-only Lock Optimization in Java Virtual Machine

LIN Chuan-wen,GU Nai-jie,HUANG Zhang-jin
DOI: https://doi.org/10.3969/j.issn.1000-1220.2013.05.032
2013-01-01
Abstract:Java virtual machine uses locking mechanism to achieve synchronization of data structure shared by multiple threads.The shared data structure is usually only be read in the critical areas,which are maintained by locking mechanism.Read-only lock is that when a thread stays in a read-only critical section,other threads can directly enter the read-only critical sections without waiting.Read-only lock can greatly improve the synchronization performance of locking mechanism.The locking mechanism of java virtual machine can be divided in lightweight lock and heavyweight lock.When the threads conflict,JVM will shift from lightweight lock to heavyweight lock.In this paper,a read-only optimization framework is proposed.It contains two levels,lightweight lock and heavyweight lock.The read-only optimization algorithm of lightweight lock can reduce the overhead of atomic operations.The read-only optimization algorithm of heavyweight lock can allow multiple threads simultaneously access to the read-only critical areas.Finally,the read-only lock optimization was achieved in HotSpot virtual machine,and the experiments were did in Loongson3A.The test cases contained single-threaded Java program,multi-threaded Java programs,and SPECjvm2008.The experimental results showed that the optimization method can significantly reduce the overhead when the threads entrying and exiting read-only critical section,and improve the synchronization performance of Java virtual machine.
What problem does this paper attempt to address?