OmniaGM commented on code in PR #15836: URL: https://github.com/apache/kafka/pull/15836#discussion_r1586109183
########## core/src/main/scala/kafka/server/BrokerServer.scala: ########## @@ -389,9 +389,17 @@ class BrokerServer( authorizer = config.createNewAuthorizer() authorizer.foreach(_.configure(config.originals)) - val fetchManager = new FetchManager(Time.SYSTEM, - new FetchSessionCache(config.maxIncrementalFetchSessionCacheSlots, - KafkaServer.MIN_INCREMENTAL_FETCH_SESSION_EVICTION_MS)) + // The FetchSessionCache is divided into config.numIoThreads shards, each responsible + // for sessionIds falling in [Max(1, shardNum * sessionIdRange), (shardNum + 1) * sessionIdRange) + val sessionIdRange = Int.MaxValue / config.numIoThreads + val fetchSessionCaches = Range(0, config.numIoThreads) Review Comment: `0 to config.numIoThreads` is usually more preferred to scala than `Range` ########## core/src/main/scala/kafka/server/BrokerServer.scala: ########## @@ -389,9 +389,17 @@ class BrokerServer( authorizer = config.createNewAuthorizer() authorizer.foreach(_.configure(config.originals)) - val fetchManager = new FetchManager(Time.SYSTEM, - new FetchSessionCache(config.maxIncrementalFetchSessionCacheSlots, - KafkaServer.MIN_INCREMENTAL_FETCH_SESSION_EVICTION_MS)) + // The FetchSessionCache is divided into config.numIoThreads shards, each responsible + // for sessionIds falling in [Max(1, shardNum * sessionIdRange), (shardNum + 1) * sessionIdRange) + val sessionIdRange = Int.MaxValue / config.numIoThreads + val fetchSessionCaches = Range(0, config.numIoThreads) Review Comment: And same as @chia7712 comment before `config.numIoThreads` is listed as broker dynamic config so what would happened when this change. ########## core/src/main/scala/kafka/server/FetchSession.scala: ########## @@ -430,6 +439,9 @@ class FullFetchContext(private val time: Time, } cachedPartitions } + // We select a shard randomly out of the available options + val shard = ThreadLocalRandom.current().nextInt(caches.size) + val cache = caches.apply(shard); Review Comment: you don't need apply `caches(shard)` is enough -- 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