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



##########
File path: core/src/main/scala/kafka/security/authorizer/AclAuthorizer.scala
##########
@@ -130,6 +130,10 @@ class AclAuthorizer extends Authorizer with Logging {
 
   @volatile
   private var aclCache = new 
scala.collection.immutable.TreeMap[ResourcePattern, VersionedAcls]()(new 
ResourceOrdering)
+
+  private val resourceCache = new 
scala.collection.mutable.HashMap[ResourceIndex,
+    scala.collection.mutable.HashSet[String]]()

Review comment:
       Use Immutable collections:
   
   Benchmark                                           (aclCount)  
(denyPercentage)  (resourceCount)  Mode  Cnt     Score      Error  Units
   AclAuthorizerBenchmark.testAclsIterator                     50               
100           200000  avgt    5  4132.824 ± 2967.122  ms/op
   AclAuthorizerBenchmark.testAuthorizeByResourceType          50               
100           200000  avgt    5    46.733 ±    5.397  ms/op
   AclAuthorizerBenchmark.testAuthorizer                       50               
100           200000  avgt    5     6.844 ±    0.915  ms/op
   AclAuthorizerBenchmark.testUpdateCache                      50               
100           200000  avgt    5  7219.696 ± 4018.189  ms/op
   JMH benchmarks done
   
   
   
   Use Mutable collections:
   
   AclAuthorizerBenchmark.testUpdateCache                      50               
100           200000  avgt    5  4927.832 ± 2570.786  ms/op
   
   
   When aclCount = 50, denyPercentage = 100, resourceCount = 200000, the time 
cost is 2.3 seconds more with immutable collections. But since adding 100 * 
20000 ACL bindings only takes ~7 seconds, I think the performance should be 
acceptable.




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