Repository navigation
ORC-1138 Optimizes the read of streams in ORC by combining multiple nearby reads into a single read, optionally allowing the retention or drop of the extra bytes - #1072
Conversation
Optimizes the read of streams in ORC by combining multiple nearby reads a single read, optionally allowing the retention or drop of the extra bytes. * minSeekSize: If separation between multiple reads is within minSeekSize then these are combined into a single read * minSeekSizeTolerance: Helps in the decisioning of whether to retain the extra bytes (extra memory) or take extra CPU to drop the unwanted bytes
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Thank you, @pavibhai .
cc @williamhyun
| Integer.MAX_VALUE - 1024, "When reading stripes >2GB, specify max limit for the chunk size."), | ||
| ORC_MIN_DISK_SEEK_SIZE("orc.min.disk.seek.size", | ||
| "hive.exec.orc.min.disk.seek.size", | ||
| 0, |
dongjoon-hyun
left a comment
There was a problem hiding this comment.
I'm not sure about the change on BufferChunk.equals method. Are you sure, @pavibhai ?
| return (chunk != null && ob.chunk != null && chunk.equals(ob.chunk)) | ||
| || (chunk == null && ob.chunk == null | ||
| && offset == ob.offset | ||
| && getLength() == ob.getLength()); |
There was a problem hiding this comment.
This looks like breaking the contact of equals.
There was a problem hiding this comment.
It looks like the offset/length comparison is missing when chunck != null, how about this
return Objects.equals(chunk, ob.chunk) && offset == ob.offset && getLength() == ob.getLength();There was a problem hiding this comment.
I would agree with @guiyanakuang we should have the comparison on offset and length. I include that proposal in the revision.
@dongjoon-hyun I am using this currently only in the tests, so I don't mind reverting this back and having this custom comparison in the tests.
There was a problem hiding this comment.
@dongjoon-hyun I have reverted this and included this comparison logic in the unit test.
IMO it is more thorough to check for offset and length in the equals. We can take that up independent of this patch.
|
cc @pgaref and @guiyanakuang , too |
| "When determining contiguous reads, gaps within this size are " | ||
| + "read contiguously and not seeked. Default value of zero disables this " | ||
| + "optimization"), | ||
| ORC_MIN_DISK_SEEK_SIZE_TOLERANCE("orc.min.disk.seek.size.tolerance", |
There was a problem hiding this comment.
Thanks for sharing the patch. AWS S3 connectors by default has readahead (mostly set to 64 or 128KB). So in a way, the data is read in addition to what is requested for.
- Would this patch be different from that?
- There can be cases when this could be reading more than necessary and throwing off the read bytes later. Would that cause perf penalties?
There was a problem hiding this comment.
Would this patch be different from that?
I can see the following differences:
- In this case the decision of reading extra bytes is based on the read plan in ORC as compared to a simple read ahead
- We will not request extra if the read does not intend on going there
- In our tests we are seeing 4MB seems to work well as shown in the benchmark results
- This can additionally be tweaked to other FS by configuring these values based on FS
There can be cases when this could be reading more than necessary and throwing off the read bytes later. Would that cause perf penalties?
There will be a trade-off between memory and cpu, the option to both read the extra bytes and drop the extra bytes is configurable allowing one to turn both or one of them off as the need demands.
| + "read contiguously and not seeked. Default value of zero disables this " | ||
| + "optimization"), | ||
| ORC_MIN_DISK_SEEK_SIZE_TOLERANCE("orc.min.disk.seek.size.tolerance", | ||
| "hive.exec.orc.min.disk.seek.size.tolerance", 0.00, |
There was a problem hiding this comment.
Can we remove this Hive conf? Actually, Apache Hive has no future release plan to use this, doesn't it? I'm a little reluctant to add a misleading Hive configuration from Apache ORC side if there is no agreement from Apache Hive community.
There was a problem hiding this comment.
@dongjoon-hyun Agreed, I have reverted both the properties to use the ORC configuration
|
Thank you for updates, @pavibhai . |
| ORC_MIN_DISK_SEEK_SIZE_TOLERANCE("orc.min.disk.seek.size.tolerance", | ||
| "orc.min.disk.seek.size.tolerance", 0.00, | ||
| "Define the tolerance for for extra bytes read as a result of " | ||
| + "orc.min.disk.seek.size. If the (bytesRead - bytesNeeded) / bytesNeeded" |
There was a problem hiding this comment.
bytesNeeded" -> bytesNeeded "
| * @param last the last range to read | ||
| * @param allocateDirect should we use direct buffers | ||
| */ | ||
| static void readRanges(FSDataInputStream file, |
There was a problem hiding this comment.
Do you think we can keep this in some way, @pavibhai ? Although it's impl package, we know that some downstream like Hive and Flink is using our internals. If possible, we should not remove anything for safety.
There was a problem hiding this comment.
I checked out hive@master, flink@master and I don't see any references to this method.
I think it should be fine to remove this method. As you called out given that it is in impl I think we should be ok cleaning up a method that is package local.
There was a problem hiding this comment.
Thank you for checking, @pavibhai . However, it wasn't okay at all. Please see the history.
ORC-685: Add ReaderImpl.extractFileTail back (#570)
ORC-677: Add a deprecated legacy constructor SargApplier back (#557)
ORC-676. Add getRawDataSizeFromColIndices back to ReaderImpl (#555)
ORC-671. Add OrcTail.getStripeStatistics back for backward compatiblility
Is there any difficulty to keep this method, @pavibhai ?
There was a problem hiding this comment.
Hive and Flink were just examples here because they didn't use the last Apache ORC yet due to those breaking change from our side. Please check our Adopter page. I don't think it's safe for new Improvement PR to remove something in the feature release.
https://orc.apache.org/docs/adopters.html
Even Apache ORC 2.0, I'd avoid this kind approach.
There was a problem hiding this comment.
Hive is using <orc.version>1.6.9</orc.version> and Flink is using <orc.version>1.5.6</orc.version> because Apache ORC breaks like this. Even for the implementation package, Apache ORC community had better conservative instead of moving away from our customers.
There was a problem hiding this comment.
So you are recommending that any member that is not private should be assumed to be public? Is that correct?
There was a problem hiding this comment.
Thanks for the quick call to clarify this.
I have added the deleted method back. There is some code duplication as a result of this in the method, if you are ok with rewriting this method with the new code while retaining the same interface I can do that as well.
| return last; | ||
| } | ||
|
|
||
| static BufferChunk findSingleRead(BufferChunk first) { |
There was a problem hiding this comment.
Please move function to the original line after the original comment because this is public.
There was a problem hiding this comment.
it is package local moved
| } | ||
| } | ||
|
|
||
| static void readDiskRanges(FSDataInputStream file, |
There was a problem hiding this comment.
ditto. We should put this public method after the method description.
There was a problem hiding this comment.
moved the package local method as suggested
| * @param minSeekSizeTolerance allowed tolerance for extra bytes in memory as a result of | ||
| * minSeekSize | ||
| */ | ||
| static void readDiskRanges(FSDataInputStream file, |
There was a problem hiding this comment.
Do we need to add this method as public? Shall we add it as private?
There was a problem hiding this comment.
sure, made it private
|
Could you revise the PR title, @pavibhai ? |
dongjoon-hyun
left a comment
There was a problem hiding this comment.
+1, LGTM. Thank you, @pavibhai .
…nearby reads into a single read, optionally allowing the retention or drop of the extra bytes We are introducing two new configuration parameters that control how read of streams takes place in ORC * minSeekSize: If separation between multiple reads is within minSeekSize then these are combined into a single read * minSeekSizeTolerance: Helps in the decisioning of whether to retain the extra bytes (extra memory) or take extra CPU to drop the unwanted bytes This leads to significant time savings (and cost also) when dealing with AWS S3. Reads with gaps e.g. reading alternate columns shows a significant penalty 5.8s vs 1.4s with the patch. * New Unit Tests were added * None of the existing tests were changed Closes apache#1072 Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Optimizes the read of streams in ORC by combining multiple nearby reads a single read, optionally allowing the retention or drop of the extra bytes.
What changes were proposed in this pull request?
We are introducing two new configuration parameters that control how read of streams takes place in ORC
Why are the changes needed?
This leads to significant time savings (and cost also) when dealing with AWS S3. Reads with gaps e.g. reading alternate columns shows a significant penalty 5.8s vs 1.4s with the patch.
How was this patch tested?