hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Giovanni Matteo Fumarola (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-14102) Performance improvement in BlockPlacementPolicyDefault
Date Wed, 28 Nov 2018 19:37:00 GMT

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

Giovanni Matteo Fumarola commented on HDFS-14102:
-------------------------------------------------

Thanks [~belugabehr] . Committed to trunk.

> Performance improvement in BlockPlacementPolicyDefault
> ------------------------------------------------------
>
>                 Key: HDFS-14102
>                 URL: https://issues.apache.org/jira/browse/HDFS-14102
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>            Reporter: BELUGA BEHR
>            Assignee: BELUGA BEHR
>            Priority: Minor
>             Fix For: 3.3.0
>
>         Attachments: HDFS-14102.1.patch, HDFS-14102.2.patch, HDFS-14102.3.patch
>
>
>  
> {code:java|title=BlockPlacementPolicyDefault.java}
>     // 1. Check that all locations are different.
>     // 2. Count locations on different racks.
>     Set<String> racks = new TreeSet<>();
>     for (DatanodeInfo dn : locs)
>       racks.add(dn.getNetworkLocation());
> ...
>     racks.size(){code}
>  
>  Here, the code is counting the number of distinct Network Locations. However, it is
using a TreeSet which has overhead to maintain item order and uses a linked structure internally.
This overhead is unneeded since all that is required here is a count.
> {quote}A NavigableSet implementation based on a TreeMap. The elements are ordered using
their natural ordering, or by a Comparator provided at set creation time, depending on which
constructor is used.
>  This implementation provides guaranteed log(n) time cost for the basic operations (add,
remove and contains).
> [https://docs.oracle.com/javase/7/docs/api/java/util/TreeSet.html]
> {quote}
>  
>  Use Java streams for readability and because it uses a {{HashSet}} under the covers
to perform the distinct action. {{HashSet}} uses an array internally and has constant time
performance for the {{add}} method.
> [https://github.com/apache/hadoop/blob/27978bcb66a9130cbf26d37ec454c0b7fcdc2530/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java#L1042]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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


Mime
View raw message