Parallelize prunedVxlanTopology
* Parallelize prunedVxlanTopology
reachableEdge runs 2 traceroutes. when there are many edges, parallelizing can give a significant speedup
@@ -2,6 +2,7 @@ package org.batfish.datamodel.vxlan;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Table;
import com.google.common.collect.Table.Cell;
@@ -183,8 +184,9 @@ public final class VxlanTopologyUtils {
assert scope != null;
NetworkConfigurations nc = NetworkConfigurations.of(configurations);
MutableGraph<VxlanNode> graph = GraphBuilder.undirected().allowsSelfLoops(false).build();
- initialVxlanTopology.getGraph().edges().stream()
+ initialVxlanTopology.getGraph().edges().parallelStream()
.filter(edge -> reachableEdge(edge, nc, tracerouteEngine))
+ .collect(ImmutableList.toImmutableList())
.forEach(edge -> graph.putEdge(edge.nodeU(), edge.nodeV()));
return new VxlanTopology(graph);
} finally {
