ekuvardin commented on code in PR #18293:
URL: https://github.com/apache/kafka/pull/18293#discussion_r2198335513


##########
jmh-benchmarks/src/main/java/org/apache/kafka/jmh/acl/AuthorizerBenchmark.java:
##########
@@ -89,13 +90,19 @@ public class AuthorizerBenchmark {
     private List<Action> actions = new ArrayList<>();
     private RequestContext authorizeContext;
     private RequestContext authorizeByResourceTypeContext;
+    private AclBindingFilter filter;
+    private AclOperation op;
+    private ResourceType resourceType;
 
     Random rand = new Random(System.currentTimeMillis());
     double eps = 1e-9;
 
     @Setup(Level.Trial)
     public void setup() throws Exception {
         authorizer = new StandardAuthorizer();
+        filter = AclBindingFilter.ANY;
+        op = AclOperation.READ;
+        resourceType = ResourceType.TOPIC;

Review Comment:
   In old test version
   
   ```
     @Benchmark
       public void testAclsIterator() {
           authorizer.acls(AclBindingFilter.ANY);
       }
   ```
   
   The JIT sees that we use methods with a single parameter and try to fold it. 
JIT can go inside methods and remove unnecessary if clauses.
   
   Alexey Shipilev wrote about it.
   
   
https://github.com/openjdk/jmh/blob/master/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java
   
   Put constant in @setup we create a steady state.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to