Browse Prior Art Database

Method and Apparatus for Workload-Aware Synchronization Mechanism in Multi-threaded Java Applications Disclosure Number: IPCOM000227693D
Publication Date: 2013-May-13
Document File: 4 page(s) / 68K

Publishing Venue

The Prior Art Database


Lock based synchronization is one of the most widely used synchronization method in multi-process and/or multi-thread programming model. From the performance aspect, time cost on acquire a lock before entering the critical section from each process/thread have a great impact on the overall performance of a program, especially with the trend that multi-core processors have been widely adopted from high-end servers to desktop and mobile, where efficiently usage of the multi-core resources is critical for system performance, the lock performance issue becomes more and more important. The type and characterize of locks varies from lock wait time (time between request a lock and acquire the lock) and overhead perspective. In this article, an adaptive lock mechanism is proposed to dynamically select a proper lock type based on real time workload in the system, it yields a better tradeoff between lock wait time and runtime overhead than traditional fixed lock type thus benefit the overall application performance. The article also proposes the related apparatus to implement the adaptive lock mechanism in common JVMs.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 51% of the total text.

Page 01 of 4

Method and Apparatus for Workload-Aware Synchronization Mechanism in Multi-threaded Java Applications

Multi-core/multi-thread based servers have become mainstreams in market. In order to take full advantages of this kind of platforms, multi-threaded programming is widely adopted in Java applications. Meanwhile, lock contention has to be inevitably introduced to protect share resources from simultaneous access/manipulation in a multi-threaded environment. So the performance of Java lock contention is critical to the whole application's throughput and scalability.

In current commercial JVM implementation, a 3-tier spin-lock monitor model is involved. Unfortunately, in this model, the spin count is a fixed value which could lead to bad performance in most cases. For example, when system workload is heavy, the thread, which cannot acquire the monitor, will spin a while to

try to obtain the monitor instead of sleeping directly. This operation would waste precious CPU clock cycles, On the contrary, when the system workload is

light, if the thread is blocked, computing resource would be wasted.

for (spin2) {
if (test_and_set(spinlock, UNOWNED, OWNED) == SUCCESS) {

    goto success;
for (spin1) {} //busy waiting

} block_enter();

To address the above problem, a adaptive lock mechanism is proposed in this article. The idea is, if the current system workload is low, the system should bias to the usage of SPIN lock because it will have shorter lock wait time although it will occupy more CPU time; if the system workload is heavy, the system should bias to the usage of YIELD or even BLOCK, because it will release the CPU and let other running thread to execute on CPU. In any case, the purpose is to improve the overall throughput of the system.

The approach mainly needs 2 components. The first one is the monitoring component to gather system workload metric in the OS layer. For example, the number of running thread can be used as a system workload metric. The second one is the lock controller we implemented...