What is Java ThreadSanitizer and Heap Monitoring?

Video overview of useful Java tools from Google developers
07 August 2017   1103


Popular general-purpose programming language and computing platform

Code health is important for Google, and team have many tools to help Google's Java developers write correct and performant code. The following presentation presents two such tools: Java ThreadSanitizer and Heap Profiling. Java ThreadSanitizer is used during testing, and helps to find data races. Heap Profiling is used in production, and is concerned with efficient monitoring of heap usage. Both dive into the depths of the JVM, with many interesting technical challenges.

ThreadSanitizer (TSAN) is a well-known dynamic data race detection tool based on LLVM. . For many years, Google's Java developers had no tool to detect data races.  There is a strong desire to see data races across the Java/JNI boundary to facilitate debugging. Hence, team have added enough instrumentation in the JVM and the JDK to allow the TSAN runtime to understand Java synchronization and see Java fields.

Some of challenges encountered:

  • adapting to TSAN's fixed-offset instrumentation when Java objects get moved,
  • the need to track *all* sources of user-visible synchronization in the JVM (including j.u.concurrent),
  • the need to annotate JDK classes for correct-by-JMM races,
  • correct forwarding of signal handling,
  • symbolization of race reports.

Despite this, there has been a steady stream of adoption by internal teams over the years. Another aspect of Google tooling is understanding the memory footprint and how to effectively reduce it. One constraint is having the mechanism on by default and, as a
consequence, the system must have a low overhead. The solution is the second tool called Heap Profiling. The solution provides users with statistical information about where the Java program is allocating its memory by providing stacktraces. It tracks via the Garbage Collection's passes what objects have been collected to offer insight on objects that are heavily churning and those that are remaining in the heap. This information allows users to understand what allocation hotspots exist, which are causes for heap growth, and what objects are often Garbage Collected. To push the feature forward, a JEP was created (JDK-8171119) and work has gone at a steady pace to provide heap allocation understanding with a low overhead. The following presentation will showcase the system, what tools were built on top of the data, how it is used in Google, and why it is important for Java engineers.

In conclusion, both tools presented provide insight on the JVM: Java ThreadSanitizer helps understand thread concurrency and Heap Monitoring provides insight the memory allocation.

What's new in IntelliJ IDEA 2018.2?

New version of popular IDE improved Spring and Spring Boot support
18 July 2018   47

The new version of IDE IntelliJ IDEA from JetBrains under the number 2018.2 has introduced several functions for developers using Spring and Spring Boot frameworks. Among the innovations: support for Spring Integration, runtime diagrams, library bin management and many minor fixes and improvements.

New features of IntelliJ IDEA

Now you can visualize the components in the system using the new Spring Integration diagram. All versions above 5.0 are supported.

Spring Integratio Diagram
Spring Integration Diagram

It shows all the gateways, channels and bridges of the application, regardless of whether they are configured using Java or XML annotations.

The IDE also received code completion and navigation for such integration annotations as @BridgeTo/From and @EnablePublisher:

Integration Annotations
Integration Annotations

In the new version of IntelliJ IDEA, you can view the dependencies during the execution of the Spring Boot application as a diagram through the control panel. To do this, go to the "Endpoints" section and enable the "Diagram Mode" function:

Runtime Dependencies
Runtime Dependencies

If there are too many beans in the project, the non-user codes can be disabled using the new "Show / Hide Library Beans" switch:

Show / Hide library beans
Show / Hide library beans

In addition, in 2018.2, you can start, modify, and test the display of HTTP requests in the "Endpoints" tab:

HTTP request
HTTP request

A complete list of improvements and changes is available in the technical update document. According to the developers, a lot of work has been done to improve performance in large projects.