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

LogTargetHandle::print should check if log level is enabled

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 16
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b23

      Description

      An early check in LogTargetHandle::print like this can reduce overhead by not dropping into code that initialize LogDecorations et.c. This saves around 100k instructions on VM bootstrap, and can reduce cost of not logging in a few places.

      diff --git a/src/hotspot/share/logging/logHandle.hpp b/src/hotspot/share/logging/logHandle.hpp
      index 3df30ac2900..fad63649b28 100644
      --- a/src/hotspot/share/logging/logHandle.hpp
      +++ b/src/hotspot/share/logging/logHandle.hpp
      @@ -91,7 +91,9 @@ public:
         void print(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) {
           va_list args;
           va_start(args, fmt);
      - _tagset->vwrite(_level, fmt, args);
      + if (is_enabled()) {
      + _tagset->vwrite(_level, fmt, args);
      + }
           va_end(args);
         }
       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              redestad Claes Redestad
              Reporter:
              redestad Claes Redestad
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: