Skip to content
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

Free unused buffer in chunk supplier during reset #23724

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package com.facebook.presto.orc;

import com.facebook.airlift.log.Logger;
import io.airlift.slice.Slice;
import io.airlift.slice.SliceOutput;
import io.airlift.slice.Slices;
Expand Down Expand Up @@ -344,6 +345,7 @@ private void closeChunk()
// reusing the buffers.
private static class ChunkSupplier
{
private static final Logger log = Logger.get(ChunkSupplier.class);
private final int maxChunkSize;

private final List<byte[]> bufferPool = new ArrayList<>();
Expand All @@ -363,6 +365,14 @@ public ChunkSupplier(int minChunkSize, int maxChunkSize)

public void reset()
{
if (!bufferPool.isEmpty()) {
log.info("Reset unused buffers, used %d chunks (%d bytes), unused %d chunks (%d bytes)",
usedBuffers.size(),
usedBuffers.stream().mapToInt(b -> b.length).sum(),
bufferPool.size(),
bufferPool.stream().mapToInt(b -> b.length).sum());
bufferPool.clear();
}
bufferPool.addAll(0, usedBuffers);
usedBuffers.clear();
}
Expand Down
Loading