steveloughran commented on a change in pull request #2307:
URL: https://github.com/apache/hadoop/pull/2307#discussion_r490146585
##########
File path:
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStream.java
##########
@@ -180,9 +205,13 @@ private int readOneBlock(final byte[] b, final int off,
final int len) throws IO
// Enable readAhead when reading sequentially
if (-1 == fCursorAfterLastRead || fCursorAfterLastRead == fCursor ||
b.length >= bufferSize) {
+ LOG.debug("Sequential read with read ahead size of {}", bufferSize);
bytesRead = readInternal(fCursor, buffer, 0, bufferSize, false);
} else {
- bytesRead = readInternal(fCursor, buffer, 0, b.length, true);
+ // Enabling read ahead for random reads as well to reduce number of
remote calls.
+ int lengthWithReadAhead = Math.min(b.length + readAheadRange,
bufferSize);
+ LOG.debug("Random read with read ahead size of {}",
lengthWithReadAhead);
+ bytesRead = readInternal(fCursor, buffer, 0, lengthWithReadAhead,
true);
Review comment:
Based on the S3A experience (which didn't always read into a buffer,
BTW), the "penalty" of having a large readahead range is there is more data to
drain when you want to cancel the read (ie. a seek out of range).
That code does the draining in the active thread. If that were to be done in
a background thread, the penalty of a larger readahead would be less, as you
would only see a delay from the draining if there were no free HTTPS
connections in the pool. Setting up a new HTTPS connection is expensive though.
If there were no free HTTPS connections in the pool, you would be better off
draining the stream in the active thread. Maybe.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]