private static PooledByteBufAllocator createPooledByteBufAllocator()

in common/src/main/java/org/apache/uniffle/common/util/GrpcNettyUtils.java [34:64]


  private static PooledByteBufAllocator createPooledByteBufAllocator(
      boolean preferDirect,
      boolean allowCache,
      int numCores,
      int pageSize,
      int maxOrder,
      int smallCacheSize,
      int normalCacheSize) {
    numCores = NettyUtils.defaultNumThreads(numCores);
    if (pageSize == 0) {
      pageSize = PooledByteBufAllocator.defaultPageSize();
    }
    if (maxOrder == 0) {
      maxOrder = PooledByteBufAllocator.defaultMaxOrder();
    }
    if (smallCacheSize == 0) {
      smallCacheSize = PooledByteBufAllocator.defaultSmallCacheSize();
    }
    if (normalCacheSize == 0) {
      normalCacheSize = PooledByteBufAllocator.defaultNormalCacheSize();
    }
    return new PooledByteBufAllocator(
        preferDirect && PlatformDependent.directBufferPreferred(),
        Math.min(PooledByteBufAllocator.defaultNumHeapArena(), numCores),
        Math.min(PooledByteBufAllocator.defaultNumDirectArena(), preferDirect ? numCores : 0),
        pageSize,
        maxOrder,
        allowCache && smallCacheSize != -1 ? smallCacheSize : 0,
        allowCache && normalCacheSize != -1 ? normalCacheSize : 0,
        allowCache && PooledByteBufAllocator.defaultUseCacheForAllThreads());
  }