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



##########
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.testUpdateCache          50               100         
  200000  avgt    5  10639.073 ± 3470.889  ms/op
   
   
   Use Mutable collections:
   
   AclAuthorizerBenchmark.testUpdateCache                      50               
100           200000  avgt    5  4927.832 ± 2570.786  ms/op
   
   
   The time cost doubled with immutable collections. But since adding 100 * 
20000 ACL bindings only takes 10 seconds, adding 20000 ACL binding takes only 
100 ms, which should be acceptable.

##########
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.testUpdateCache          50               100         
  200000  avgt    5  10639.073 ± 3470.889  ms/op
   
   
   Use Mutable collections:
   
   AclAuthorizerBenchmark.testUpdateCache                      50               
100           200000  avgt    5  4927.832 ± 2570.786  ms/op
   
   
   The time cost doubled with immutable collections. But since adding 100 * 
20000 ACL bindings only takes 10 seconds, adding 20000 ACL binding takes only 
100 ms on average, which 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