Thomas Vachuska
Committed by Yuta Higuchi

Measuring topology performance. Fixing a defect that caused us to run w/o accumu…

…lator when config file was not present.

Change-Id: I5ad538b8a441cd6ff2aefea49a0def10b8e0f4d5
...@@ -22,17 +22,23 @@ import org.onlab.onos.net.Provided; ...@@ -22,17 +22,23 @@ import org.onlab.onos.net.Provided;
22 */ 22 */
23 public interface Topology extends Provided { 23 public interface Topology extends Provided {
24 24
25 - // FIXME: Following is not true right now. It is actually System.nanoTime(),
26 - // which has no relation to epoch time, wall clock, etc.
27 /** 25 /**
28 - * Returns the time, specified in milliseconds since start of epoch, 26 + * Returns the time, specified in system nanos of when the topology
29 - * when the topology became active and made available. 27 + * became available.
30 * 28 *
31 - * @return time in milliseconds since start of epoch 29 + * @return time in system nanos
32 */ 30 */
33 long time(); 31 long time();
34 32
35 /** 33 /**
34 + * Returns the time, specified in system nanos of how long the topology
35 + * took to compute.
36 + *
37 + * @return elapsed time in system nanos
38 + */
39 + long computeCost();
40 +
41 + /**
36 * Returns the number of SCCs (strongly connected components) in the 42 * Returns the number of SCCs (strongly connected components) in the
37 * topology. 43 * topology.
38 * 44 *
......
...@@ -66,9 +66,9 @@ public class DefaultTopologyProvider extends AbstractProvider ...@@ -66,9 +66,9 @@ public class DefaultTopologyProvider extends AbstractProvider
66 implements TopologyProvider { 66 implements TopologyProvider {
67 67
68 private static final int MAX_THREADS = 8; 68 private static final int MAX_THREADS = 8;
69 - private static final int DEFAULT_MAX_EVENTS = 200; 69 + private static final int DEFAULT_MAX_EVENTS = 1000;
70 - private static final int DEFAULT_MAX_BATCH_MS = 60; 70 + private static final int DEFAULT_MAX_IDLE_MS = 10;
71 - private static final int DEFAULT_MAX_IDLE_MS = 30; 71 + private static final int DEFAULT_MAX_BATCH_MS = 50;
72 72
73 // FIXME: Replace with a system-wide timer instance; 73 // FIXME: Replace with a system-wide timer instance;
74 // TODO: Convert to use HashedWheelTimer or produce a variant of that; then decide which we want to adopt 74 // TODO: Convert to use HashedWheelTimer or produce a variant of that; then decide which we want to adopt
...@@ -116,15 +116,15 @@ public class DefaultTopologyProvider extends AbstractProvider ...@@ -116,15 +116,15 @@ public class DefaultTopologyProvider extends AbstractProvider
116 @Activate 116 @Activate
117 public synchronized void activate(ComponentContext context) { 117 public synchronized void activate(ComponentContext context) {
118 executor = newFixedThreadPool(MAX_THREADS, namedThreads("topo-build-%d")); 118 executor = newFixedThreadPool(MAX_THREADS, namedThreads("topo-build-%d"));
119 + accumulator = new TopologyChangeAccumulator();
120 + logConfig("Configured");
121 +
119 modified(context); 122 modified(context);
120 123
121 providerService = providerRegistry.register(this); 124 providerService = providerRegistry.register(this);
122 deviceService.addListener(deviceListener); 125 deviceService.addListener(deviceListener);
123 linkService.addListener(linkListener); 126 linkService.addListener(linkListener);
124 127
125 - log.info("Configured with maxEvents = {}; maxBatchMs = {}; maxIdleMs = {}",
126 - maxEvents, maxBatchMs, maxIdleMs);
127 -
128 isStarted = true; 128 isStarted = true;
129 triggerRecompute(); 129 triggerRecompute();
130 log.info("Started"); 130 log.info("Started");
...@@ -149,6 +149,7 @@ public class DefaultTopologyProvider extends AbstractProvider ...@@ -149,6 +149,7 @@ public class DefaultTopologyProvider extends AbstractProvider
149 public void modified(ComponentContext context) { 149 public void modified(ComponentContext context) {
150 if (context == null) { 150 if (context == null) {
151 accumulator = new TopologyChangeAccumulator(); 151 accumulator = new TopologyChangeAccumulator();
152 + logConfig("Reconfigured");
152 return; 153 return;
153 } 154 }
154 155
...@@ -163,6 +164,7 @@ public class DefaultTopologyProvider extends AbstractProvider ...@@ -163,6 +164,7 @@ public class DefaultTopologyProvider extends AbstractProvider
163 164
164 s = (String) properties.get("maxIdleMs"); 165 s = (String) properties.get("maxIdleMs");
165 newMaxIdleMs = isNullOrEmpty(s) ? maxIdleMs : Integer.parseInt(s); 166 newMaxIdleMs = isNullOrEmpty(s) ? maxIdleMs : Integer.parseInt(s);
167 +
166 } catch (Exception e) { 168 } catch (Exception e) {
167 newMaxEvents = DEFAULT_MAX_EVENTS; 169 newMaxEvents = DEFAULT_MAX_EVENTS;
168 newMaxBatchMs = DEFAULT_MAX_BATCH_MS; 170 newMaxBatchMs = DEFAULT_MAX_BATCH_MS;
...@@ -174,9 +176,13 @@ public class DefaultTopologyProvider extends AbstractProvider ...@@ -174,9 +176,13 @@ public class DefaultTopologyProvider extends AbstractProvider
174 maxBatchMs = newMaxBatchMs; 176 maxBatchMs = newMaxBatchMs;
175 maxIdleMs = newMaxIdleMs; 177 maxIdleMs = newMaxIdleMs;
176 accumulator = maxEvents > 1 ? new TopologyChangeAccumulator() : null; 178 accumulator = maxEvents > 1 ? new TopologyChangeAccumulator() : null;
177 - log.info("Reconfigured with maxEvents = {}; maxBatchMs = {}; maxIdleMs = {}", 179 + logConfig("Reconfigured");
178 - maxEvents, maxBatchMs, maxIdleMs); 180 + }
179 } 181 }
182 +
183 + private void logConfig(String prefix) {
184 + log.info("{} with maxEvents = {}; maxBatchMs = {}; maxIdleMs = {}; accumulator={}",
185 + prefix, maxEvents, maxBatchMs, maxIdleMs, accumulator != null);
180 } 186 }
181 187
182 188
......
...@@ -65,6 +65,7 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -65,6 +65,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
65 new TarjanGraphSearch<>(); 65 new TarjanGraphSearch<>();
66 66
67 private final long time; 67 private final long time;
68 + private final long computeCost;
68 private final TopologyGraph graph; 69 private final TopologyGraph graph;
69 70
70 private final SCCResult<TopologyVertex, TopologyEdge> clusterResults; 71 private final SCCResult<TopologyVertex, TopologyEdge> clusterResults;
...@@ -104,6 +105,7 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -104,6 +105,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
104 105
105 this.broadcastSets = buildBroadcastSets(); 106 this.broadcastSets = buildBroadcastSets();
106 this.infrastructurePoints = findInfrastructurePoints(); 107 this.infrastructurePoints = findInfrastructurePoints();
108 + this.computeCost = Math.max(0, System.nanoTime() - time);
107 } 109 }
108 110
109 @Override 111 @Override
...@@ -112,6 +114,11 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -112,6 +114,11 @@ public class DefaultTopology extends AbstractModel implements Topology {
112 } 114 }
113 115
114 @Override 116 @Override
117 + public long computeCost() {
118 + return computeCost;
119 + }
120 +
121 + @Override
115 public int clusterCount() { 122 public int clusterCount() {
116 return clusters.size(); 123 return clusters.size();
117 } 124 }
...@@ -453,6 +460,7 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -453,6 +460,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
453 public String toString() { 460 public String toString() {
454 return toStringHelper(this) 461 return toStringHelper(this)
455 .add("time", time) 462 .add("time", time)
463 + .add("computeCost", computeCost)
456 .add("clusters", clusterCount()) 464 .add("clusters", clusterCount())
457 .add("devices", deviceCount()) 465 .add("devices", deviceCount())
458 .add("links", linkCount()) 466 .add("links", linkCount())
......
...@@ -65,6 +65,7 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -65,6 +65,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
65 new TarjanGraphSearch<>(); 65 new TarjanGraphSearch<>();
66 66
67 private final long time; 67 private final long time;
68 + private final long computeCost;
68 private final TopologyGraph graph; 69 private final TopologyGraph graph;
69 70
70 private final SCCResult<TopologyVertex, TopologyEdge> clusterResults; 71 private final SCCResult<TopologyVertex, TopologyEdge> clusterResults;
...@@ -104,6 +105,7 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -104,6 +105,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
104 105
105 this.broadcastSets = buildBroadcastSets(); 106 this.broadcastSets = buildBroadcastSets();
106 this.infrastructurePoints = findInfrastructurePoints(); 107 this.infrastructurePoints = findInfrastructurePoints();
108 + this.computeCost = Math.max(0, System.nanoTime() - time);
107 } 109 }
108 110
109 @Override 111 @Override
...@@ -112,6 +114,11 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -112,6 +114,11 @@ public class DefaultTopology extends AbstractModel implements Topology {
112 } 114 }
113 115
114 @Override 116 @Override
117 + public long computeCost() {
118 + return computeCost;
119 + }
120 +
121 + @Override
115 public int clusterCount() { 122 public int clusterCount() {
116 return clusters.size(); 123 return clusters.size();
117 } 124 }
...@@ -453,6 +460,7 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -453,6 +460,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
453 public String toString() { 460 public String toString() {
454 return toStringHelper(this) 461 return toStringHelper(this)
455 .add("time", time) 462 .add("time", time)
463 + .add("computeCost", computeCost)
456 .add("clusters", clusterCount()) 464 .add("clusters", clusterCount())
457 .add("devices", deviceCount()) 465 .add("devices", deviceCount())
458 .add("links", linkCount()) 466 .add("links", linkCount())
......