You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Yutong Xiao (Jira)" <ji...@apache.org> on 2021/12/18 11:09:00 UTC
[jira] [Created] (HBASE-26604) Replace new allocation with ThreadLocal in CellBlockBuilder to reduce GC
Yutong Xiao created HBASE-26604:
-----------------------------------
Summary: Replace new allocation with ThreadLocal in CellBlockBuilder to reduce GC
Key: HBASE-26604
URL: https://issues.apache.org/jira/browse/HBASE-26604
Project: HBase
Issue Type: Task
Reporter: Yutong Xiao
Assignee: Yutong Xiao
In CellBlockBuilder decompress method, we currently allocate a new ByteBufferOutputStream object each invoke.
{code:java}
try {
// TODO: This is ugly. The buffer will be resized on us if we guess wrong.
//TODO: reuse buffers.
bbos = new ByteBufferOutputStream(osInitialSize);
IOUtils.copy(cis, bbos);
bbos.close();
return bbos.getByteBuffer();
} finally {
CodecPool.returnDecompressor(poolDecompressor);
}
{code}
We can use a ThreadLocal variable to reuse the buffer in each Thread. As:
{code:java}
try {
// TODO: This is ugly. The buffer will be resized on us if we guess wrong.
if (this.decompressBuff.get() == null) {
this.decompressBuff.set(new ByteBufferOutputStream(osInitialSize));
}
ByteBufferOutputStream localBbos = this.decompressBuff.get();
localBbos.clear();
IOUtils.copy(cis, localBbos);
return localBbos.getByteBuffer();
} finally {
CodecPool.returnDecompressor(poolDecompressor);
}
{code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)