Hexiaoqiao commented on PR #6423:
URL: https://github.com/apache/hadoop/pull/6423#issuecomment-2109258078
When we want to improve it, the following patch should be better, because it
also involve `list.add` where LinkedList is less cost.
```
---
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java
+++
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java
@@ -311,8 +311,8 @@ public List<NodePlan> computePlan(double
thresholdPercent) {
ExecutorService executorService =
Executors.newFixedThreadPool(poolSize);
List<Future<NodePlan>> futureList = new LinkedList<>();
- for (int x = 0; x < nodesToProcess.size(); x++) {
- final DiskBalancerDataNode node = nodesToProcess.get(x);
+ for (DiskBalancerDataNode n : nodesToProcess) {
+ final DiskBalancerDataNode node = n;
final Planner planner = PlannerFactory
.getPlanner(PlannerFactory.GREEDY_PLANNER, node,
thresholdPercent);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]