4 ## Copyright (c) 2010-2017 Intel Corporation
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
10 ## http://www.apache.org/licenses/LICENSE-2.0
12 ## Unless required by applicable law or agreed to in writing, software
13 ## distributed under the License is distributed on an "AS IS" BASIS,
14 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ## See the License for the specific language governing permissions and
16 ## limitations under the License.
19 from testerset import *
20 from time import sleep
26 from itertools import chain
28 from csvwriter import *
30 from progress import *
31 from proxmaxssprobe import *
33 def runTest(minSetupRate, testParam):
34 print "Running test with following parameters:"
35 print testParam.toString();
37 testers = testerSet(config._test_systems, config._max_port_rate, testParam);
39 thresh = testParam.getConnections();
40 p = Progress(thresh, ["connections", "setup rate", "reTX"], False);
44 testers.startForkJoin();
45 testers.wait_links_up();
46 testers.start_cores();
48 print "Running until convergence (%s connections)" % str(thresh)
49 while (not converged):
50 sleep(config._interCheckDuration)
51 testers.update_stats();
52 tot = testers.get_total_connections();
53 tot_retx = testers.get_total_retx();
54 rates = testers.get_rates();
55 curSetupRate = testers.get_setup_rate();
56 ierrors = testers.getIerrors();
58 converged = tot >= thresh;
60 if (loop_count > 0 and curSetupRate < minSetupRate):
61 reason = str(curSetupRate) + " < " + str(minSetupRate);
62 print "Current setup rate is lower than min setup rate: " + reason
65 if (not testers.conditionsGood()):
66 print "conditions are bad: " + testers.getReason();
71 p.setProgress(tot, [tot, curSetupRate, tot_retx]);
76 skipTime = config._skipTime
77 print "Connection threshold reached, waiting for " + str(skipTime) + "s, conditions checked = " + str(config._checkConditions)
79 skipTime -= config._interCheckDuration
80 sleep(config._interCheckDuration)
81 testers.update_stats();
82 if (config._checkConditions and not testers.conditionsGood()):
83 print "conditions are bad: " + testers.getReason();
87 testers.tx_rate_meassurement();
89 testLength = config._testLength
90 print "Waiting final " + str(testLength) + "s"
91 while (testLength > 0):
92 testLength -= config._interCheckDuration
93 sleep(config._interCheckDuration)
94 testers.update_stats();
95 if (not testers.conditionsGood()):
96 print "conditions are bad: " + testers.getReason();
100 rates = testers.tx_rate_meassurement();
105 def find_ss(tot_conn, maxSetupRate, ss_max):
110 # The setup rate must be in [0.2% of total connections, maxSetupRate]
111 # Also, it must not be hihger than 50% of the total connections
112 min_setup_rate = tot_conn / 500;
114 if (min_setup_rate > maxSetupRate):
115 print "min setup rate > max setup rate: " + str(min_setup_rate) + " > " + str(maxSetupRate);
116 return valid_ss, speed_ss;
117 if (maxSetupRate > tot_conn / 2):
118 print "maximum setup rate (" + str(maxSetupRate) + ") is more than 50% of " + str(tot_conn)
119 return valid_ss, speed_ss;
121 accuracy = 10**config._accuracy
123 ss_hi = int(round(ss_max * accuracy,0))
125 iterationOverride = [ss_hi, ss_lo];
126 # Binary search for highest speed scaling
127 while (ss_lo <= ss_hi):
128 if (iterationCount < len(iterationOverride)):
129 ss = iterationOverride[iterationCount]
131 ss = (ss_lo + ss_hi)/2;
133 testParam = TestParameters(maxSetupRate, tot_conn, float(ss)/accuracy);
135 success, rates = runTest(min_setup_rate, testParam);
136 print "success = " + str(success) + ", rates = " + str(rates)
137 if (success == True):
138 valid_ss.append(float(ss)/accuracy);
139 speed_ss.append(sum(rates)/len(rates))
144 return valid_ss, speed_ss;
146 def get_highest_ss_and_speed(valid_ss, speed_ss):
148 highest_speed = None;
150 for i in range(len(valid_ss)):
151 if(highest_ss == None or highest_ss < valid_ss[i]):
152 highest_ss = valid_ss[i];
153 highest_speed = speed_ss[i];
154 return highest_ss, highest_speed;
157 ts = config._test_systems[0];
158 test_system = ProxMaxSSProbe(ts);
159 max_ss = test_system.getMaxSS();
161 return floor((max_ss * (10**config._accuracy)))/(10**config._accuracy)
164 config.parse(sys.argv[0], sys.argv[1:])
166 err = config.getErrorTestOne();
167 if (err is not None):
168 print "Invalid configuration: " + err;
171 print config.toString()
173 if (config._once is not None):
174 maxSetupRate = int(config._once[0])
175 minSetupRate = maxSetupRate/500
176 connections = int(config._once[1])
177 speedScaling = float(config._once[2])
179 testParam = TestParameters(maxSetupRate, connections, speedScaling)
180 success, rates = runTest(minSetupRate, testParam)
181 print "success = " + str(success) + ", port rates = " + str(rates)
185 msr_list += range(4000, 20000, 2000)
186 msr_list += range(20000, 100000, 20000)
187 msr_list += range(100000, 300000, 50000)
188 msr_list += range(300000, 800001, 100000);
190 conn_list = [1*10**5, 2*10**5, 4*10**5, 8*10**5, 1*10**6, 2*10**6]
192 summary_file = CsvWriter()
193 summary_file.open(config._output_file_name)
196 for tot_conn in conn_list:
198 if (msr >= tot_conn/2):
203 print "Search will include " + str(tot_it) + " parameter combinations"
204 print "Will search for highest link utilization"
206 # If the lowest msr was a for n connections, then the lowest msr
207 # for n + 1 connections can't be lower than a.
208 low_sr = msr_list[0];
210 max_ss = get_max_ss()
212 high_ss = Decimal(max_ss)
214 globalProgress = Progress(tot_it)
215 globalProgress.setProgress(0);
216 for tot_conn in conn_list:
220 globalProgress.incrProgress();
223 print "skipping " + str(msr) + " since it is lower than " + str(low_sr)
226 print globalProgress.toString();
228 valid_ss, speed_ss = find_ss(tot_conn, msr, high_ss)
229 print "valid ss = " + str(valid_ss)
230 print "valid speeds = " + str(speed_ss)
232 if (len(valid_ss) > 0):
233 highest_ss, highest_speed = get_highest_ss_and_speed(valid_ss, speed_ss);
234 summary_file.write([msr, tot_conn, highest_ss, highest_speed]);
236 if (not had_success):
240 all_ss = all_ss + valid_ss;
242 if (len(all_ss) > 0):
243 high_ss = max(all_ss);