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

LogTargetHandle::print should check if log level is enabled

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 16
    • None
    • hotspot
    • b23

      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);
         }
       

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

              Created:
              Updated:
              Resolved: