[ 
https://issues.apache.org/jira/browse/HBASE-5979?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14050511#comment-14050511
 ] 

Vladimir Rodionov commented on HBASE-5979:
------------------------------------------

{quote}
 The advantage of pread is that it doesn't hold any locks, so multiple gets can 
proceed at the same time. 
{quote}

Interesting .. This is th code snippet from FSInputStream (Hadoop 2.2)
{code}
  @Override
  public int read(long position, byte[] buffer, int offset, int length)
    throws IOException {
    synchronized (this) {
      long oldPos = getPos();
      int nread = -1;
      try {
        seek(position);
        nread = read(buffer, offset, length);
      } finally {
        seek(oldPos);
      }
      return nread;
    }
  }
{code}

*Positional read is implemented with a lock*. DFSInputStream extends the above 
class and does not override the default implementation. You have no parallelism 
even for simple gets.

 


> Non-pread DFSInputStreams should be associated with scanners, not 
> HFile.Readers
> -------------------------------------------------------------------------------
>
>                 Key: HBASE-5979
>                 URL: https://issues.apache.org/jira/browse/HBASE-5979
>             Project: HBase
>          Issue Type: Improvement
>          Components: Performance, regionserver
>            Reporter: Todd Lipcon
>
> Currently, every HFile.Reader has a single DFSInputStream, which it uses to 
> service all gets and scans. For gets, we use the positional read API (aka 
> "pread") and for scans we use a synchronized block to seek, then read. The 
> advantage of pread is that it doesn't hold any locks, so multiple gets can 
> proceed at the same time. The advantage of seek+read for scans is that the 
> datanode starts to send the entire rest of the HDFS block, rather than just 
> the single hfile block necessary. So, in a single thread, pread is faster for 
> gets, and seek+read is faster for scans since you get a strong pipelining 
> effect.
> However, in a multi-threaded case where there are multiple scans (including 
> scans which are actually part of compactions), the seek+read strategy falls 
> apart, since only one scanner may be reading at a time. Additionally, a large 
> amount of wasted IO is generated on the datanode side, and we get none of the 
> earlier-mentioned advantages.
> In one test, I switched scans to always use pread, and saw a 5x improvement 
> in throughput of the YCSB scan-only workload, since it previously was 
> completely blocked by contention on the DFSIS lock.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to