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

Jinglun edited comment on HDFS-14908 at 10/22/19 2:44 AM:
----------------------------------------------------------

Introduce a new method startsWith(String str, int sStart, int sLen, String 
prefix, int pStart, int pLen) to replace String.startsWith() in isParent(). The 
new method compares strings with index so we can avoid copying the strings.

Test file is TestV2.java

*Result*

Case 1:

path=    /dir0/dir1/dir2/dir3

parent=/dir0/dir1
||Time||10,000,000,000||
|startsWith()|40,070ms|
|isParent()|33,152ms|

Case 2:

path=    /dir0/dir1/dir2/dir3

parent=/dir0/dir2
||Time||10,000,000,000||
|startsWith()|39,779ms|
|isParent()|32,019ms|

Case 3:

path=    dir0/dir1/dir2/dir3

parent=dir0/dir1
||Time||10,000,000,000||
|startsWith()| 34,331ms|
|isParent()| 2,298ms|

Case 4:

path=    /dir0/dir1/dir2/dir3/

parent=/dir0/dir1/
||Time||10,000,000,000||
|startsWith()|44,839ms|
|isParent()|37,311ms |

 

*Conclusion*

After optimizing, isParent() is a little faster than Strings.startsWith(). 


was (Author: lijinglun):
Introduce a new method startsWith(String str, int sStart, int sLen, String 
prefix, int pStart, int pLen) to replace String.startsWith() in isParent(). The 
new method compares strings with index so we can avoid copying the strings.

Test file is TestV2.java

*Result*

Case 1:

path=    /dir0/dir1/dir2/dir3

parent=/dir0/dir1
||Time||10,000,000,000||
|startsWith()| 40,070ms|
|isParent()|33,152ms|

Case 2:

path=    /dir0/dir1/dir2/dir3

parent=/dir0/dir2
||Time||10,000,000,000||
|startsWith()| 39,779ms|
|isParent()|32,019 |

Case 3:

path=    dir0/dir1/dir2/dir3

parent=dir0/dir1
||Time||10,000,000,000||
|startsWith()| 34,331ms|
|isParent()| 2,298ms|

Case 4:

path=    /dir0/dir1/dir2/dir3/

parent=/dir0/dir1/
||Time||10,000,000,000||
|startsWith()| 44,839ms|
|isParent()|37,311ms |
 

> LeaseManager should check parent-child relationship when filter open files.
> ---------------------------------------------------------------------------
>
>                 Key: HDFS-14908
>                 URL: https://issues.apache.org/jira/browse/HDFS-14908
>             Project: Hadoop HDFS
>          Issue Type: Bug
>    Affects Versions: 3.1.0, 3.0.1
>            Reporter: Jinglun
>            Assignee: Jinglun
>            Priority: Minor
>         Attachments: HDFS-14908.001.patch, HDFS-14908.002.patch, 
> HDFS-14908.003.patch, Test.java, TestV2.java
>
>
> Now when doing listOpenFiles(), LeaseManager only checks whether the filter 
> path is the prefix of the open files. We should check whether the filter path 
> is the parent/ancestor of the open files.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to