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

Colin Patrick McCabe commented on HDFS-6097:
--------------------------------------------

bq. DFSInputStream#tryReadZeroCopy: It seems unnecessary to copy pos to curPos. 
The value of curPos is never changed throughout the method, so it's always the 
same as pos. This is a synchronized method, so I don't expect pos to get 
mutated on a different thread.

This is actually an optimization I made.  I wanted to avoid making a memory 
access each time, since I use this variable a lot.  By copying it to a local 
variable, it becomes a lot more obvious to the optimizer that it can't change.  
It's possible that Java will perform this optimization automatically, but I'm 
skeptical because we're calling a lot of functions here.  It seems like it 
would require a sophisticated optimizer to realize that there was no code path 
that changed this variable.

bq. TestEnhancedByteBufferAccess: Let's remove the commented out lines and the 
extra indentation on the Assert.fail line.

OK.

bq. Let's use try-finally blocks to guarantee cleanup of cluster, fs, fsIn and 
fsIn2.

I guess I've started to skip doing this on unit tests.  My rationale is that if 
the test fails, cleanup isn't really that important (the surefire process will 
simply terminate).  In the meantime, try... finally blocks complicate the code 
and often make it hard to see where a test originally failed.  Oftentimes if 
things get messed up, {{FileSystem#close}} or {{MiniDFSCluster#shutdown}} will 
throw an exception.  And you end up seeing this unhelpful exception rather than 
the root cause of the problem displayed in the maven test output.  On the other 
hand, I suppose going without try... finally could encourage people to copy 
flawed code, so I guess that's the counter-argument.

> zero-copy reads are incorrectly disabled on file offsets above 2GB
> ------------------------------------------------------------------
>
>                 Key: HDFS-6097
>                 URL: https://issues.apache.org/jira/browse/HDFS-6097
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: hdfs-client
>    Affects Versions: 2.4.0
>            Reporter: Colin Patrick McCabe
>            Assignee: Colin Patrick McCabe
>         Attachments: HDFS-6097.003.patch
>
>
> Zero-copy reads are incorrectly disabled on file offsets above 2GB due to 
> some code that is supposed to disable zero-copy reads on offsets in block 
> files greater than 2GB (because MappedByteBuffer segments are limited to that 
> size).



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

Reply via email to