IBM's Java Diagnostics, part 3rd

Source: Internet
Author: User
Tags thread

Diagnosing synchronization and locking problems using the Java-oriented lock Analyzer

Reduce lock contention and improve performance

Introduction: Java™-oriented IBM® Lock Analyzer is available from Alphaworks, which allows real-time lock monitoring of running Java applications. Lock contention degrades application performance, and the tool highlights the thread in which the lock contention occurs. Developers can use this information to modify their applications to reduce lock contention, thereby improving performance. This paper introduces the IBM Lock Analyzer for Java, introduces its infrastructure and ponders the future development direction of the tool.

Many Java applications today support concurrent programming by using threads to leverage the capabilities of the language. Many threads can share the same data object, but if the part of the application that controls the thread is poorly designed, you may experience a lock contention problem to degrade performance.

For example, in a multithreaded application, thread synchronization problems may occur if multiple threads access the same resources for read-write access. If one thread tries to read a file and another thread writes it, it may corrupt the data. To solve this problem, the Java language allows one thread to acquire a proprietary lock on an object, thereby preventing any other thread from accessing it. Once the thread finishes processing the object, it frees the object so that other threads can access it. However, if the application is not carefully designed, this mechanism may result in a higher level of contention.

If a lock is in use and another thread attempts to acquire it, a lock contention occurs. A higher level of contention may occur if the lock is frequently acquired and/or held for a longer period of time. A higher level of lock contention (which many threads attempt to access) becomes a bottleneck in the system, because each running thread pauses execution until the lock it needs becomes available, limiting the performance of the application.

Use JLA to prevent lock problems

The Java-oriented IBM Lock Analyzer (JLA) is a new tool in Alphaworks that can run on any platform running IBM-provided Java SDK or JRE version 5.0 or later, performing a lock analysis on the active application to highlight the activity of the thread and provides insight into the frequency of lock contention. This view can help resolve lock contention issues and performance issues.

JLA, while running an existing Java application, collects all the lock information for the application. Record each lock and its details, such as the time it was persisted, whether it was contending, and the percentage of time it blocked the thread from trying to get it. The tool consists of a run-time library and a front-end graphical user interface that must be loaded when you start the application that you want to monitor, which can display results and performance analysis.

JLA Design Details

The JLA consists of the following two packages:

JLAagent. The package, which is platform-specific, consists of a platform based library file and a set of Java classes packaged into jars that provide a connection to the Java Virtual Machine (JVM) to gather lock statistics about the running application.

Jlagui. The package is written using Swing, which is not platform-independent and provides a graphical user interface.

The local library in JLAagent is written in C and uses the Java Virtual Machine tool interface (Java Machine Tool INTERFACE,JVM TI). This interface provides methods to control the execution of applications running in the JVM. With this interface, you can collect thread statistics using the features available in the IBM-published JVM. You can also allow the JVM to load this local library at startup by modifying the startup command for the Java application that you want to analyze. The local library then uses the Java class packaged with it to create a platform MBean server that provides a mechanism to allow Jlagui to connect to JLAagent.

After the MBean server is started, Jlagui can request lock statistics for the running application by navigating the server to the local library and navigating to the running JVM. Because JLAagent and Jlagui are connected by Mbeans, they are not necessarily running on the same machine; Jlagui can also connect to an MBean server from anywhere on the network.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.