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