-
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NormalMemoryRegionCache's arraysize is over booked #2925
Comments
@garretwu thanks for reporting... I will check and fix it |
@garretwu I'm right you say it should get the 7th cache bin(start from0) . right ? |
you are right, @normanmaurer. That is what I mean. |
Thanks for clarify!
|
Totally forgot about this. Will look into it or would you want to submit a pr @garretwu ? We love contributions :) |
@garretwu what you think about provide a PR for this ? I'm still not 100 % sure I understand the issue correctly, so maybe it would be the easiest to just have you fix it ;) |
sure, I could create a PR:) |
This would be awesome!
|
Hi @normanmaurer. mvn test pass. end to end test: |
…Cache 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
…Cache 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
…Cache 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
Fixed by #3624 |
…hreadCache 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
When create NormalMemoryRegionCache for PoolThreadCache. The array size is decided by:
int max = Math.min(area.chunkSize, maxCachedBufferCapacity);
int arraySize = Math.max(1, max / area.pageSize);
So most likely it is decided by maxCachedBufferCapacity/area.pageSize, with maxCachedBufferCapacity=2M the array size will be 2^8 = 256.
when we try to get normal cache the index is pre-processed by log2():
PoolThreadCache.cacheForNormal():
int idx = log2(normCapacity >> numShiftsNormalHeap);
return cache(normalHeapCaches, idx);
A 2M cache entry will get from the 8th cache bin(start from 0).
The space for NormalMemoryRegionCache is over booked, though it will not impact correctness(just a little performance..).
The text was updated successfully, but these errors were encountered: