-
Notifications
You must be signed in to change notification settings - Fork 62
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
reuse decompressor to reduce memory consumption #1
base: master
Are you sure you want to change the base?
Conversation
@@ -331,6 +339,8 @@ public void close() throws IOException { | |||
decompressor.decompress(b, 0, b.length); | |||
} | |||
super.close(); | |||
if(reuseDecompressor) |
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.
should be done after 'verifyChecksum'. (in a finally clause, to be safe).
+1. thanks Yu. |
@@ -86,7 +87,11 @@ public CompressionInputStream createInputStream(InputStream in, | |||
|
|||
@Override | |||
public CompressionInputStream createInputStream(InputStream in) throws IOException { | |||
return createInputStream(in, createDecompressor()); | |||
/* create a decompressor and tell LzoInputStream to reuse it | |||
* (return it to the pool when LzoInputStream is closed. |
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.
missing closing paren
simplify decompressor reuse (reuse decompressors for both cases)
@@ -111,6 +112,9 @@ public void close() throws IOException { | |||
} | |||
closed = true; | |||
} | |||
//return the compressor to the pool for later reuse; | |||
//the returnCompressor handles nulls. | |||
CodecPool.returnCompressor(compressor); |
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.
for correctness, this should be inside 'if (!closed)' check.
+1. thanks for multiple iterations. |
currently we create a new decompressor for each lzo RecordReader. Each lzo decompressor currently uses 0.5MB memory(two 256K buffers) and we can run out of memory when we create many lzo record readers.