-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: Optimize PrestoSerializer decompress buffer #11836
base: main
Are you sure you want to change the base?
feat: Optimize PrestoSerializer decompress buffer #11836
Conversation
✅ Deploy Preview for meta-velox canceled.
|
0a803d5
to
7cfade1
Compare
7e78159
to
5dfe257
Compare
Can you help review again? Thanks! @Yuhta |
velox/common/memory/ByteStream.cpp
Outdated
auto newBuf = folly::IOBuf::wrapBuffer( | ||
current_->buffer + current_->position, readBytes); | ||
if (result) { | ||
result->prev()->appendChain(std::move(newBuf)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order of buffers here is incorrect. Just do result->appendToChain(std::move(newBuf))
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order is same with IOBufOutputStream::getIOBuf(), appendToChain is also OK. I will change as you say.
common::CompressionKind compressionKind, | ||
memory::MemoryPool& pool) { | ||
const auto codec = common::compressionKindToCodec(compressionKind); | ||
if (dynamic_cast<BufferInputStream*>(source)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just do the dynamic_cast
once: if (const auto* bufferSource = dynamic_cast<BufferInputStream*>(source))
auto byteStream = createStream(byteRanges); | ||
auto bufferStream = dynamic_cast<BufferInputStream*>(byteStream.get()); | ||
for (int offset = 0; offset < streamSize;) { | ||
auto iobuf = bufferStream->readBytes(streamSize / 8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not testing the case one IOBuf chain cross 2 buffers. Let's cover that as well.
Read the BufferInputStream by new added function readBytes to avoid copying from the buffer cache. Extract the uncompress process to a new function can help release the compressed buffer in time.
FileInputStream reuse the read buffer, so we can get the IOBuf without copy only if the required bytes is in one buffer, which is not the common case, so I don't do the optimization for it.