lirui-apache commented on code in PR #8463:
URL: https://github.com/apache/hadoop/pull/8463#discussion_r3167465565


##########
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java:
##########
@@ -1230,7 +1230,9 @@ void actualGetFromOneDataNode(final DNAddrPair datanode, 
final long startInBlk,
         long beginReadMS = Time.monotonicNow();
         int nread = 0;
         int ret;
-        while (true) {
+        // Stop once the slice is filled; an extra read with remaining()==0
+        // can trigger wasted slow-lane I/O in SCR.
+        while (tmp.hasRemaining()) {

Review Comment:
   Thanks for the review. I hit the issue when I was testing short circuit 
read. If we call `BlockReaderLocal.read` with `tmp.remaining() == 0`, it will 
hit the slow lane via `BlockReaderLocal::readWithBounceBuffer::fillDataBuf`, 
which will actually allocate and read into the bounce buffer. But since user 
buffer is filled, we cannot drain into it and the read data is thrown away and 
wasted.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to