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
Incorrect allocations value for PoolArena (tiny / small / normal) #6282
Comments
@isdom this is because of the caches... when you deallocate the buffers they will first end up in ThreadLocal caches. Only after these removed from the caches they are really deallocated. You can disable the caches to see it. |
@normanmaurer but I have already disable ThreadLocal caches by set JVM flag:
and Take a look at the following test code:
I think PoolArena try to allocate tiny or small buffer, when PoolSubpage is empty( head.next == head ), tiny or small buffer initialized via function allocateNormal(buf, reqCapacity, normCapacity) , but allocateNormal always increase normal's counter at code1 and code2, these two increment action could be replaced by following code:
Please check PoolArena's allocation increment code (tiny / small / normal ) again, thanks @normanmaurer |
@isdom doh! You are right. Want to do a PR or should I take care ? |
@normanmaurer OK,Let me try... |
@isdom ok cool... Would be nice if just would calculate if its tiny/small/normal allocation one time though and not need to do multiple times 👍 |
… for normal allocations.
Motivation: Disable ThreadLocal Cache, then allocate Pooled ByteBuf and release all these buffers, PoolArena's tiny/small/normal allocation count is incorrect. Modifications: - Calculate PoolArena's tiny/small/normal allocation one time - Add testAllocationCounter TestCase Result: Fixes #6282 .
Fixed by #6288 |
Motivation: Disable ThreadLocal Cache, then allocate Pooled ByteBuf and release all these buffers, PoolArena's tiny/small/normal allocation count is incorrect. Modifications: - Calculate PoolArena's tiny/small/normal allocation one time - Add testAllocationCounter TestCase Result: Fixes netty#6282 .
Motivation: Disable ThreadLocal Cache, then allocate Pooled ByteBuf and release all these buffers, PoolArena's tiny/small/normal allocation count is incorrect. Modifications: - Calculate PoolArena's tiny/small/normal allocation one time - Add testAllocationCounter TestCase Result: Fixes netty#6282 .
I found some PoolArena allocations value was incorrect, more specifically is:
and
When I alloc Pooled ByteBuf & and release all these Bufs,
Expected behavior
PoolArena's Metric SHOULD meet the following conditions:
Actual behavior
BUT now result:
It seems some tiny & small allocations increase normal's counter, I export PoolArenaMetric as MBean by code and show MBean by Web using zkoss, see below:
In this case,
numAllocations(2404) == numDeallocations(2404)
BUT
equals
(numNormalAllocations - numNormalDeallocations) // == 26
Steps to reproduce
I start test code with VM flag (disable thread local cache):
then alloc some ByteBuf and release Bufs.
Minimal yet complete reproducer code (or URL to code)
TestCase to reproduce: https://github.com/isdom/jocean-http/blob/6bc6cfa9ae1e71395a4dd52355b1b0a8365bb530/jocean-http/src/test/java/org/jocean/netty/buffer/PooledByteBufAllocatorTestCase.java
and make sure run this test with VM flag: -XX:MaxDirectMemorySize=96M
It fail at:
output :
If this is confirmed as a issue,I can open a PR to fix it.
Netty version
netty-all-4.1.7.Final
JVM version (e.g.
java -version
)java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
OS version (e.g.
uname -a
)Linux xxx 3.10.0-327.22.2.el7.x86_64 #1 SMP Thu Jun 23 17:05:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: