BELUGA BEHR created HDFS-14296: ---------------------------------- Summary: Prefer ArrayList over LinkedList in VolumeScanner Key: HDFS-14296 URL: https://issues.apache.org/jira/browse/HDFS-14296 Project: Hadoop HDFS Issue Type: Improvement Components: datanode Affects Versions: 3.2.0 Reporter: BELUGA BEHR Assignee: BELUGA BEHR Attachments: HDFS-14296.1.patch
{quote}The {{size}}, {{isEmpty}}, {{get}}, {{set}}, {{iterator}}, and {{listIterator}} operations run in constant time. - ArrayList {quote} However, for a {{LinkedList}}, the entire list must be traversed to get to the desired index. Like [Here|https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/VolumeScanner.java#L384] Most of the time, the List is being iterated, which is quicker over a primitive array than walking a LinkedList. There is one place where an item is removed, potentially from the middle of the list [here|https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/VolumeScanner.java#L736] but the speed of removing from the middle of the list isn't bad; it's a system native array shift, and it only happens on the off chance that a block pool is removed from the DataNode. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-dev-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-dev-h...@hadoop.apache.org