Reduce memory usage in writer with more memory efficient output buffer implementation #24913
Conversation
b88e026 to
04a0df7
Compare
04a0df7 to
4d7394d
Compare
4d7394d to
4b14d15
Compare
|
Thanks for the release note! Formatting and rephrasing suggestions to help follow the Release Notes Guidelines: |
Thanks. updated |
|
Please format the release note with a row of three ` above and below, like this: |
5eeb72e to
48e410b
Compare
| bufferPool.size(), | ||
| bufferPool.stream().mapToInt(b -> b.length).sum()); | ||
| bufferPool.clear(); | ||
| System.setProperty("RESET_OUTPUT_BUFFER", "RESET_OUTPUT_BUFFER"); |
|
Can you please rebase it? Also would be nice to run this change in Vader to get 1-2k samples. I'll do a second round after that. |
48e410b to
8323da4
Compare
|
Rebased. What is Vader? How do I run this change in Vader?
|
|
Discussed with Sergii offline, ran Validation Service (Vader), results looks good, ~2k successful samples without failures https://fburl.com/scuba/dwrf_reader_checksum/dzgyy5xi |
8323da4 to
7bc6321
Compare
|
LGTM, please do the minor change I requested and we will land it. |
7bc6321 to
5252922
Compare
|
rebased |
| @Override | ||
| public void writeHeader(int value) | ||
| { | ||
| buffer[bufferPosition] = (byte) (value & 0x00_00FF); |
There was a problem hiding this comment.
Please change to a more concise:
buffer[bufferPosition++] = (byte) (value & 0x00_00FF);
buffer[bufferPosition++] = (byte) ((value & 0x00_FF00) >> 8);
buffer[bufferPosition++] = (byte) ((value & 0xFF_0000) >> 16);
Description
Currently ChunkedSliceOutput is used for storing compressed output in writer. It managed list of buffers with size of power of 2 (e.g. 8k, 16k, 32k), and reuse buffers after flushing. It could leads to extra memory usage and OOM due to 1) mismatch in compressed output size and buffer size, 2) reusing buffers and not freeing buffers leads to extra memory usage by design.
Common scenario which leads to OOM includes
This PR introduce OrcLazyChunkedOutputBuffer which focus on avoiding used memory.
This behavior is controlled by lazyOutputBuffer in OrcWriterOptions, and it's disabled by default.
Impact
Reduce memory usage in writer.
Test Plan
Tested with Spark workload with high memory usage.
~10% improvement in run time and resource usage (memory reservation time), reduced GC time.
Tested with general Spark workload
No change in cpu time, slight reduction in run time and GC time.