You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by go...@apache.org on 2024/02/23 11:41:49 UTC

(pinot) branch master updated: bugfix: reduce enum array allocation in QueryLogger (#12478)

This is an automated email from the ASF dual-hosted git repository.

gortiz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 1004d3b0d2 bugfix: reduce enum array allocation in QueryLogger (#12478)
1004d3b0d2 is described below

commit 1004d3b0d27e4ba48071e5f72b433b4db184dce9
Author: sullis <gi...@seansullivan.com>
AuthorDate: Fri Feb 23 03:41:44 2024 -0800

    bugfix: reduce enum array allocation in QueryLogger (#12478)
    
    Motivation:
    
    reduce enum array allocation in QueryLogger
    
    Modifications:
    
    cache QueryLogEntry.values() in a static variable
    
    Result:
    
    Java enum .values() method is invoked exactly once
    
    Additional context:
    
    https://www.gamlor.info/wordpress/2017/08/javas-enum-values-hidden-allocations/
---
 .../src/main/java/org/apache/pinot/broker/querylog/QueryLogger.java    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pinot-broker/src/main/java/org/apache/pinot/broker/querylog/QueryLogger.java b/pinot-broker/src/main/java/org/apache/pinot/broker/querylog/QueryLogger.java
index e708a9edb7..a1ccd63e6c 100644
--- a/pinot-broker/src/main/java/org/apache/pinot/broker/querylog/QueryLogger.java
+++ b/pinot-broker/src/main/java/org/apache/pinot/broker/querylog/QueryLogger.java
@@ -45,6 +45,7 @@ import static org.apache.pinot.spi.utils.CommonConstants.Broker;
 public class QueryLogger {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(QueryLogger.class);
+  private static final QueryLogEntry[] QUERY_LOG_ENTRY_VALUES = QueryLogEntry.values();
 
   private final int _maxQueryLengthToLog;
   private final RateLimiter _logRateLimiter;
@@ -82,7 +83,7 @@ public class QueryLogger {
     }
 
     final StringBuilder queryLogBuilder = new StringBuilder();
-    for (QueryLogEntry value : QueryLogEntry.values()) {
+    for (QueryLogEntry value : QUERY_LOG_ENTRY_VALUES) {
       value.format(queryLogBuilder, this, params);
       queryLogBuilder.append(',');
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org