Browse Source

Fix unnecessary allocations in ChildMemoryCircuitBreaker (#104972)

This line allocates GB/min for the capturing lambda during hot indexing
according to async-profiler. No need for that.
Armin Braun 1 year ago
parent
commit
6458cba23f

+ 3 - 1
server/src/main/java/org/elasticsearch/common/breaker/ChildMemoryCircuitBreaker.java

@@ -198,7 +198,9 @@ public class ChildMemoryCircuitBreaker implements CircuitBreaker {
     @Override
     public void addWithoutBreaking(long bytes) {
         long u = used.addAndGet(bytes);
-        logger.trace(() -> format("[%s] Adjusted breaker by [%s] bytes, now [%s]", this.name, bytes, u));
+        if (logger.isTraceEnabled()) {
+            logger.trace("[{}] Adjusted breaker by [{}] bytes, now [{}]", this.name, bytes, u);
+        }
         assert u >= 0 : "Used bytes: [" + u + "] must be >= 0";
     }