d8tltanc commented on a change in pull request #9485:
URL: https://github.com/apache/kafka/pull/9485#discussion_r541202572



##########
File path: 
jmh-benchmarks/src/main/java/org/apache/kafka/jmh/acl/AclAuthorizerBenchmark.java
##########
@@ -69,33 +73,44 @@
 @BenchmarkMode(Mode.AverageTime)
 @OutputTimeUnit(TimeUnit.MILLISECONDS)
 public class AclAuthorizerBenchmark {
-    @Param({"10000", "50000", "200000"})
+    @Param({"200000"})
     private int resourceCount;
     //no. of. rules per resource
-    @Param({"10", "50"})
+    @Param({"50"})
     private int aclCount;
 
+    @Param({"0", "20", "50", "90", "99", "99.9", "99.99", "100"})
+    private double denyPercentage;
+
     private final int hostPreCount = 1000;
     private final String resourceNamePrefix = "foo-bar35_resource-";
+    private final String resourceName = resourceNamePrefix + 95;
 
     private final AclAuthorizer aclAuthorizer = new AclAuthorizer();
     private final KafkaPrincipal principal = new 
KafkaPrincipal(KafkaPrincipal.USER_TYPE, "test-user");
     private List<Action> actions = new ArrayList<>();
     private RequestContext context;
 
+    private TreeMap<ResourcePattern, VersionedAcls> aclCache = new 
TreeMap<>(new AclAuthorizer.ResourceOrdering());
+    private scala.collection.mutable.HashMap<ResourceIndex, 
scala.collection.mutable.HashSet<String>> resourceCache =
+        new scala.collection.mutable.HashMap<>();
+    Random rand = new Random(System.currentTimeMillis());
+    double eps = 1e-9;
+
     @Setup(Level.Trial)
     public void setup() throws Exception {
-        setFieldValue(aclAuthorizer, 
AclAuthorizer.class.getDeclaredField("aclCache").getName(),
-            prepareAclCache());
+        prepareAclCache();
+        setFieldValue(aclAuthorizer, 
AclAuthorizer.class.getDeclaredField("aclCache").getName(), aclCache);
+        setFieldValue(aclAuthorizer, 
AclAuthorizer.class.getDeclaredField("resourceCache").getName(), resourceCache);
         // By adding `-95` to the resource name prefix, we cause the 
`TreeMap.from/to` call to return
         // most map entries. In such cases, we rely on the filtering based on 
`String.startsWith`
         // to return the matching ACLs. Using a more efficient data structure 
(e.g. a prefix
         // tree) should improve performance significantly).
         actions = Collections.singletonList(new Action(AclOperation.WRITE,
-            new ResourcePattern(ResourceType.TOPIC, resourceNamePrefix + 95, 
PatternType.LITERAL),
+            new ResourcePattern(ResourceType.TOPIC, resourceName, 
PatternType.LITERAL),

Review comment:
       Yeah. I was doing resourceName = resourceName + 95 to re-use this 
variable. We can revert it.




----------------------------------------------------------------
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.

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


Reply via email to