No need to release lock and acquire again when allocate normal size.
Motiviation: When tried to allocate tiny and small sized and failed to serve these out of the PoolSubPage we exit the synchronization block just to enter it again when call allocateNormal(...). Modification: Not exit the synchronized block until allocateNormal(...) is done. Result: Better performance.
This commit is contained in:
parent
70a4ad0c25
commit
833b92a5aa
@ -144,8 +144,8 @@ abstract class PoolArena<T> {
|
|||||||
table = smallSubpagePools;
|
table = smallSubpagePools;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final PoolSubpage<T> head = table[tableIdx];
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
final PoolSubpage<T> head = table[tableIdx];
|
|
||||||
final PoolSubpage<T> s = head.next;
|
final PoolSubpage<T> s = head.next;
|
||||||
if (s != head) {
|
if (s != head) {
|
||||||
assert s.doNotDestroy && s.elemSize == normCapacity;
|
assert s.doNotDestroy && s.elemSize == normCapacity;
|
||||||
@ -154,21 +154,25 @@ abstract class PoolArena<T> {
|
|||||||
s.chunk.initBufWithSubpage(buf, handle, reqCapacity);
|
s.chunk.initBufWithSubpage(buf, handle, reqCapacity);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
allocateNormal(buf, reqCapacity, normCapacity);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else if (normCapacity <= chunkSize) {
|
}
|
||||||
|
if (normCapacity <= chunkSize) {
|
||||||
if (cache.allocateNormal(this, buf, reqCapacity, normCapacity)) {
|
if (cache.allocateNormal(this, buf, reqCapacity, normCapacity)) {
|
||||||
// was able to allocate out of the cache so move on
|
// was able to allocate out of the cache so move on
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
synchronized (this) {
|
||||||
|
allocateNormal(buf, reqCapacity, normCapacity);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Huge allocations are never served via the cache so just call allocateHuge
|
// Huge allocations are never served via the cache so just call allocateHuge
|
||||||
allocateHuge(buf, reqCapacity);
|
allocateHuge(buf, reqCapacity);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
allocateNormal(buf, reqCapacity, normCapacity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void allocateNormal(PooledByteBuf<T> buf, int reqCapacity, int normCapacity) {
|
private void allocateNormal(PooledByteBuf<T> buf, int reqCapacity, int normCapacity) {
|
||||||
if (q050.allocate(buf, reqCapacity, normCapacity) || q025.allocate(buf, reqCapacity, normCapacity) ||
|
if (q050.allocate(buf, reqCapacity, normCapacity) || q025.allocate(buf, reqCapacity, normCapacity) ||
|
||||||
q000.allocate(buf, reqCapacity, normCapacity) || qInit.allocate(buf, reqCapacity, normCapacity) ||
|
q000.allocate(buf, reqCapacity, normCapacity) || qInit.allocate(buf, reqCapacity, normCapacity) ||
|
||||||
q075.allocate(buf, reqCapacity, normCapacity) || q100.allocate(buf, reqCapacity, normCapacity)) {
|
q075.allocate(buf, reqCapacity, normCapacity) || q100.allocate(buf, reqCapacity, normCapacity)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user