Improvements to IntentPerfInstaller
* adding total to log * using local devices and keys * added delay between cycles * print time if cycle is delayed Change-Id: I16a3c041dd2e920695ab782d22fe6db8abad7da8
Showing
1 changed file
with
35 additions
and
12 deletions
... | @@ -22,13 +22,13 @@ import org.apache.felix.scr.annotations.Activate; | ... | @@ -22,13 +22,13 @@ import org.apache.felix.scr.annotations.Activate; |
22 | import org.apache.felix.scr.annotations.Component; | 22 | import org.apache.felix.scr.annotations.Component; |
23 | import org.apache.felix.scr.annotations.Deactivate; | 23 | import org.apache.felix.scr.annotations.Deactivate; |
24 | import org.apache.felix.scr.annotations.Reference; | 24 | import org.apache.felix.scr.annotations.Reference; |
25 | -import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
26 | import org.onlab.util.Counter; | 25 | import org.onlab.util.Counter; |
27 | import org.onosproject.cluster.ClusterService; | 26 | import org.onosproject.cluster.ClusterService; |
28 | import org.onosproject.core.ApplicationId; | 27 | import org.onosproject.core.ApplicationId; |
29 | import org.onosproject.core.CoreService; | 28 | import org.onosproject.core.CoreService; |
30 | import org.onosproject.net.ConnectPoint; | 29 | import org.onosproject.net.ConnectPoint; |
31 | import org.onosproject.net.Device; | 30 | import org.onosproject.net.Device; |
31 | +import org.onosproject.net.MastershipRole; | ||
32 | import org.onosproject.net.PortNumber; | 32 | import org.onosproject.net.PortNumber; |
33 | import org.onosproject.net.device.DeviceService; | 33 | import org.onosproject.net.device.DeviceService; |
34 | import org.onosproject.net.flow.DefaultTrafficSelector; | 34 | import org.onosproject.net.flow.DefaultTrafficSelector; |
... | @@ -54,6 +54,8 @@ import java.util.concurrent.ExecutorService; | ... | @@ -54,6 +54,8 @@ import java.util.concurrent.ExecutorService; |
54 | import java.util.concurrent.Executors; | 54 | import java.util.concurrent.Executors; |
55 | import java.util.concurrent.TimeUnit; | 55 | import java.util.concurrent.TimeUnit; |
56 | 56 | ||
57 | +import static com.google.common.base.Preconditions.checkState; | ||
58 | +import static org.apache.felix.scr.annotations.ReferenceCardinality.MANDATORY_UNARY; | ||
57 | import static org.onlab.util.Tools.delay; | 59 | import static org.onlab.util.Tools.delay; |
58 | import static org.onlab.util.Tools.groupedThreads; | 60 | import static org.onlab.util.Tools.groupedThreads; |
59 | import static org.slf4j.LoggerFactory.getLogger; | 61 | import static org.slf4j.LoggerFactory.getLogger; |
... | @@ -66,16 +68,16 @@ public class IntentPerfInstaller { | ... | @@ -66,16 +68,16 @@ public class IntentPerfInstaller { |
66 | 68 | ||
67 | private final Logger log = getLogger(getClass()); | 69 | private final Logger log = getLogger(getClass()); |
68 | 70 | ||
69 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 71 | + @Reference(cardinality = MANDATORY_UNARY) |
70 | protected CoreService coreService; | 72 | protected CoreService coreService; |
71 | 73 | ||
72 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 74 | + @Reference(cardinality = MANDATORY_UNARY) |
73 | protected IntentService intentService; | 75 | protected IntentService intentService; |
74 | 76 | ||
75 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 77 | + @Reference(cardinality = MANDATORY_UNARY) |
76 | protected ClusterService clusterService; | 78 | protected ClusterService clusterService; |
77 | 79 | ||
78 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 80 | + @Reference(cardinality = MANDATORY_UNARY) |
79 | protected DeviceService deviceService; | 81 | protected DeviceService deviceService; |
80 | 82 | ||
81 | private ExecutorService worker; | 83 | private ExecutorService worker; |
... | @@ -90,7 +92,7 @@ public class IntentPerfInstaller { | ... | @@ -90,7 +92,7 @@ public class IntentPerfInstaller { |
90 | private Timer reportTimer; | 92 | private Timer reportTimer; |
91 | 93 | ||
92 | //FIXME make this configurable | 94 | //FIXME make this configurable |
93 | - private static final int NUM_KEYS = 10000; | 95 | + private static final int NUM_KEYS = 10_000; |
94 | 96 | ||
95 | @Activate | 97 | @Activate |
96 | public void activate() { | 98 | public void activate() { |
... | @@ -117,7 +119,7 @@ public class IntentPerfInstaller { | ... | @@ -117,7 +119,7 @@ public class IntentPerfInstaller { |
117 | // we will need to discard the first few results for priming and warmup | 119 | // we will need to discard the first few results for priming and warmup |
118 | listener = new Listener(); | 120 | listener = new Listener(); |
119 | intentService.addListener(listener); | 121 | intentService.addListener(listener); |
120 | - reportTimer = new Timer("intent-perf-reporter"); | 122 | + reportTimer = new Timer("onos-intent-perf-reporter"); |
121 | reportTimer.scheduleAtFixedRate(new TimerTask() { | 123 | reportTimer.scheduleAtFixedRate(new TimerTask() { |
122 | @Override | 124 | @Override |
123 | public void run() { | 125 | public void run() { |
... | @@ -133,6 +135,7 @@ public class IntentPerfInstaller { | ... | @@ -133,6 +135,7 @@ public class IntentPerfInstaller { |
133 | while (!stopped) { | 135 | while (!stopped) { |
134 | cycle(); | 136 | cycle(); |
135 | // TODO delay if required | 137 | // TODO delay if required |
138 | + delay(600); | ||
136 | } | 139 | } |
137 | }); | 140 | }); |
138 | 141 | ||
... | @@ -155,8 +158,13 @@ public class IntentPerfInstaller { | ... | @@ -155,8 +158,13 @@ public class IntentPerfInstaller { |
155 | 158 | ||
156 | 159 | ||
157 | private void cycle() { | 160 | private void cycle() { |
161 | + long start = System.currentTimeMillis(); | ||
158 | subset(submitted).forEach(this::withdraw); | 162 | subset(submitted).forEach(this::withdraw); |
159 | subset(withdrawn).forEach(this::submit); | 163 | subset(withdrawn).forEach(this::submit); |
164 | + long delta = System.currentTimeMillis() - start; | ||
165 | + if (delta > 1000 || delta < 0) { | ||
166 | + log.warn("Cycle took {} ms", delta); | ||
167 | + } | ||
160 | } | 168 | } |
161 | 169 | ||
162 | private Iterable<Intent> subset(Set<Intent> intents) { | 170 | private Iterable<Intent> subset(Set<Intent> intents) { |
... | @@ -181,14 +189,21 @@ public class IntentPerfInstaller { | ... | @@ -181,14 +189,21 @@ public class IntentPerfInstaller { |
181 | 189 | ||
182 | Iterator<Device> deviceItr = deviceService.getAvailableDevices().iterator(); | 190 | Iterator<Device> deviceItr = deviceService.getAvailableDevices().iterator(); |
183 | 191 | ||
184 | - if (!deviceItr.hasNext()) { | 192 | + Device ingressDevice = null; |
185 | - throw new IllegalStateException("There are no devices"); | 193 | + while (deviceItr.hasNext()) { |
194 | + Device device = deviceItr.next(); | ||
195 | + if (deviceService.getRole(device.id()) == MastershipRole.MASTER) { | ||
196 | + ingressDevice = device; | ||
197 | + break; | ||
186 | } | 198 | } |
199 | + } | ||
200 | + checkState(ingressDevice != null, "There are no local devices"); | ||
187 | 201 | ||
188 | - Device ingressDevice = deviceItr.next(); | 202 | + for (int local = 0, i = 0; local < numberOfKeys; i++) { |
189 | - | ||
190 | - for (int i = 0; i < numberOfKeys; i++) { | ||
191 | Key key = Key.of(i, appId); | 203 | Key key = Key.of(i, appId); |
204 | + if (!intentService.isLocal(key)) { | ||
205 | + continue; | ||
206 | + } | ||
192 | TrafficSelector selector = DefaultTrafficSelector.builder().build(); | 207 | TrafficSelector selector = DefaultTrafficSelector.builder().build(); |
193 | 208 | ||
194 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); | 209 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); |
... | @@ -201,7 +216,12 @@ public class IntentPerfInstaller { | ... | @@ -201,7 +216,12 @@ public class IntentPerfInstaller { |
201 | ingress, egress, | 216 | ingress, egress, |
202 | Collections.emptyList()); | 217 | Collections.emptyList()); |
203 | intents.add(intent); | 218 | intents.add(intent); |
219 | + local++; | ||
220 | + if (i % 1000 == 0) { | ||
221 | + log.info("Building intents... {} ({})", local, i); | ||
222 | + } | ||
204 | } | 223 | } |
224 | + log.info("Created {} intents", numberOfKeys); | ||
205 | } | 225 | } |
206 | 226 | ||
207 | private void prime() { | 227 | private void prime() { |
... | @@ -243,9 +263,12 @@ public class IntentPerfInstaller { | ... | @@ -243,9 +263,12 @@ public class IntentPerfInstaller { |
243 | 263 | ||
244 | public void report() { | 264 | public void report() { |
245 | StringBuilder stringBuilder = new StringBuilder(); | 265 | StringBuilder stringBuilder = new StringBuilder(); |
266 | + double total = counters.get(IntentEvent.Type.INSTALLED).throughput() + | ||
267 | + counters.get(IntentEvent.Type.WITHDRAWN).throughput(); | ||
246 | for (IntentEvent.Type type : IntentEvent.Type.values()) { | 268 | for (IntentEvent.Type type : IntentEvent.Type.values()) { |
247 | stringBuilder.append(printCounter(type)).append("; "); | 269 | stringBuilder.append(printCounter(type)).append("; "); |
248 | } | 270 | } |
271 | + stringBuilder.append(String.format("TOTAL=%.2f", total)); | ||
249 | log.info("Intent Throughput:\n{}", stringBuilder); | 272 | log.info("Intent Throughput:\n{}", stringBuilder); |
250 | } | 273 | } |
251 | 274 | ... | ... |
-
Please register or login to post a comment