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 on average, 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.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 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