Avoid auto boxing in PoolChunk#removeAvailRun (#10769)

Motivation:
PoolChunk maintains multiple PriorityQueue<Long> collections. The usage
of PoolChunk#removeAvailRun unboxes the Long values to long, and then
this method uses queue.remove(..) which will auto box the value back to
Long. This creates unnecessary allocations via Long.valueOf(long).

Modifications:
- Adjust method signature and usage of PoolChunk#removeAvailRun to avoid
boxing

Result:
Less allocations as a result of PoolChunk#removeAvailRun.
This commit is contained in:
Scott Mitchell 2020-11-03 12:08:43 -08:00 committed by Norman Maurer
parent 10af555f46
commit 32627d712a

View File

@ -250,13 +250,13 @@ final class PoolChunk<T> implements PoolChunkMetric {
assert pre == null;
}
private void removeAvailRun(long handle) {
private void removeAvailRun(Long handle) {
int pageIdxFloor = arena.pages2pageIdxFloor(runPages(handle));
PriorityQueue<Long> queue = runsAvail[pageIdxFloor];
removeAvailRun(queue, handle);
}
private void removeAvailRun(PriorityQueue<Long> queue, long handle) {
private void removeAvailRun(PriorityQueue<Long> queue, Long handle) {
queue.remove(handle);
int runOffset = runOffset(handle);
@ -335,9 +335,9 @@ final class PoolChunk<T> implements PoolChunkMetric {
//get run with min offset in this queue
PriorityQueue<Long> queue = runsAvail[queueIdx];
long handle = queue.poll();
Long handle = queue.poll();
assert !isUsed(handle);
assert handle != null && !isUsed(handle);
removeAvailRun(queue, handle);