[#2925] Bug fix for NormalMemoryRegionCache overbooked for PoolThreadCache
Motivation: When create NormalMemoryRegionCache for PoolThreadCache, we overbooked cache array size. This means unnecessary overhead for thread local cache as we will create multi cache enties for each element in cache array. Modifications: change: int arraySize = Math.max(1, max / area.pageSize); to: int arraySize = Math.max(1, log2(max / area.pageSize) + 1); Result: Now arraySize won't introduce unnecessary overhead. Changes to be committed: modified: buffer/src/main/java/io/netty/buffer/PoolThreadCache.java
This commit is contained in:
parent
418c81542b
commit
d14afe88a4
@ -129,7 +129,7 @@ final class PoolThreadCache {
|
|||||||
int cacheSize, int maxCachedBufferCapacity, PoolArena<T> area) {
|
int cacheSize, int maxCachedBufferCapacity, PoolArena<T> area) {
|
||||||
if (cacheSize > 0) {
|
if (cacheSize > 0) {
|
||||||
int max = Math.min(area.chunkSize, maxCachedBufferCapacity);
|
int max = Math.min(area.chunkSize, maxCachedBufferCapacity);
|
||||||
int arraySize = Math.max(1, max / area.pageSize);
|
int arraySize = Math.max(1, log2(max / area.pageSize) + 1);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
NormalMemoryRegionCache<T>[] cache = new NormalMemoryRegionCache[arraySize];
|
NormalMemoryRegionCache<T>[] cache = new NormalMemoryRegionCache[arraySize];
|
||||||
|
Loading…
Reference in New Issue
Block a user