Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8264323

Add a global option -Xlog:async for Unified Logging

    XMLWordPrintable

Details

    • behavioral
    • low
    • This option is new and the default behavior is same as before. Therefore, no compatibility risk will be present.
    • add/remove/modify command line option
    • Implementation

    Description

      Summary

      Add a global option -Xlog:async to the Hotspot command-line options, which directs unified logs to be written asynchronously.

      Problem

      Writing to logs may be blocked. For example, writing logs to a filesystem could be blocked by the kernel. Writing logs via a socket or other network-backed virtual filesystems could block due to network. If the block of log writing occurs when the VM wants to go to a safepoint, or initiate a handshake, then the VM can experience long pauses which then increase the response time of a Java application/service. In the worst case, hotspot may hang at a safepoint.

      Solution

      Our solution is to provide a new feature "Asynchronous Logging" for the unified logging subsystem. In asynchronous logging mode, log sites enqueue all logging messages to a buffer and a standalone thread is responsible for flushing them to the corresponding outputs. The intermediate buffer is bounded. Log entry write operations are guaranteed non-blocking. On buffer exhaustion the enqueuing message is discarded so that under no circumstances will logging block threads.

      Specification

      -Xlog:async
            Write all logging asynchronously.      

      If the user passes -Xlog:async on the command-line, then the JVM uses "Asynchronous Logging" for all logging. This feature is disabled by default.

      A new product option -XX:AsyncLogBufferSize is added, which specifies the memory budget in bytes for the intermediate buffer. The default value should be big enough to cater for most cases. Users can provide a custom value to trade memory overhead for log accuracy if they need to.

          product(size_t, AsyncLogBufferSize, 2*M,                                                   \
            "Memory budget (in bytes) for the buffer of Asynchronous Logging (-Xlog:async). ")       \
            range(100*K, 50*M)                                                                       \

      Attachments

        Issue Links

          Activity

            People

              xliu Xin Liu
              ysr Y. Ramakrishna
              David Holmes, Thomas Stuefe
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: