LogTargetHandle::print should check if log level is enabled

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 16
    • Affects Version/s: None
    • Component/s: 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);
         }
       

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

              Created:
              Updated:
              Resolved: