Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import javax.net.ssl.SSLEngine;

import io.netty.buffer.PooledByteBufAllocator;
import lombok.extern.slf4j.Slf4j;

import org.apache.bookkeeper.common.allocator.LeakDetectionPolicy;
Expand Down Expand Up @@ -1060,7 +1061,7 @@ public T setAllocatorPoolingPolicy(PoolingPolicy poolingPolicy) {
* @return the configured pooling concurrency for the allocator.
*/
public int getAllocatorPoolingConcurrency() {
return this.getInteger(ALLOCATOR_POOLING_CONCURRENCY, 2 * Runtime.getRuntime().availableProcessors());
return this.getInteger(ALLOCATOR_POOLING_CONCURRENCY, PooledByteBufAllocator.defaultNumDirectArena());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

@sunshujie1990 sunshujie1990 Jun 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value of defaultNumDirectArena is 2 * cpus https://github.com/netty/netty/blob/4e439264df0523fb6efce5f8f6c7c7fa74addd07/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java#L413-L418

Thanks for your reply. Netty default value use the min value between 2*cpus and max mem defaultChunkSize / 2 / 3 to avoid oom. And it helps me resolved bookeeper oom problem in my product environment. Can you help me to merge it?

        DEFAULT_NUM_DIRECT_ARENA = Math.max(0,
                SystemPropertyUtil.getInt(
                        "io.netty.allocator.numDirectArenas",
                        (int) Math.min(
                                defaultMinNumArena,
                                PlatformDependent.maxDirectMemory() / defaultChunkSize / 2 / 3)));

}

/**
Expand Down