@@ -82,19 +82,19 @@ private Statistics executeBenchmark() throws InterruptedException {
8282
8383 execBinarySearchStep (mConfig .getBinarySearchConfig (), searchLimits );
8484
85- do {
86- double score = execFineTuneStep (mConfig .getFineTuneConfig ());
85+ double score = execFineTuneStep (mConfig .getFineTuneConfig ());
8786
88- if (score > 0 ) {
89- break ;
90- } else if (score < -2 * mConfig .getFineTuneConfig ().getInitialStep ()) {
87+ while (score < 0 ) {
88+ if (score < -2 * mConfig .getFineTuneConfig ().getMaxInitialStep ()) {
9189 logInfoAndStdOut ("Unexpectedly bad result from fine tune, doing binary search again." );
9290 searchLimits = searchLimits .intersection (Range .atMost (mWorkersPool .getWorkerCount ()));
9391 execBinarySearchStep (mConfig .getBinarySearchConfig (), searchLimits );
9492 } else {
9593 logInfoAndStdOut ("Fine tune result uncompliant, will try again." );
9694 }
97- } while (true );
95+
96+ score = execFineTuneStep (mConfig .getFineTuneConfig (), score );
97+ }
9898
9999 Statistics stats = execCalculateStatsStep (mConfig .getStableStatsConfig ());
100100 printFinalResults (stats );
@@ -154,19 +154,25 @@ private void execBinarySearchStep(BinarySearchStepConfig config, Range<Integer>
154154 }
155155
156156 private double execFineTuneStep (FineTuneStepConfig config ) throws InterruptedException {
157+ return execFineTuneStep (config , Double .NaN );
158+ }
159+
160+ private double execFineTuneStep (FineTuneStepConfig config , double score ) throws InterruptedException {
157161 logInfoAndStdOut ("Starting fine tune step." );
158162
159- double score = complianceScore (config );
160- if (score < 0 ) {
161- int tuneDownStep = 2 * (int ) Math .min (Math .round (-score ), config .getInitialStep ());
162- do {
163- LOGGER .debug ("Fine tuning down with step: {}" , tuneDownStep );
164- setWorkerCount (Math .max (mWorkersPool .getWorkerCount () - tuneDownStep , 0 ));
165- } while (!isComplying (config ));
163+ if (Double .isNaN (score )) {
164+ score = complianceScore (config );
165+ }
166+ int tuneDownStep = 2 * (int ) Math .min (Math .round (-score ), config .getMaxInitialStep ());
167+ while (score < 0 ) {
168+ LOGGER .debug ("Fine tuning down with step: {}" , tuneDownStep );
169+ setWorkerCount (Math .max (mWorkersPool .getWorkerCount () - tuneDownStep , 0 ));
170+ score = complianceScore (config );
166171 }
167172
168173 int complyingCount = mWorkersPool .getWorkerCount ();
169- for (int step = config .getInitialStep (); step > 1 ; step /= 2 ) {
174+ int initialStep = (int ) Math .min (Math .round (2 * score ), config .getMaxInitialStep ());
175+ for (int step = initialStep ; step >= 1 ; step /= 2 ) {
170176 while (true ) {
171177 LOGGER .debug ("Fine tuning up with step: {}" , step );
172178 setWorkerCount (complyingCount + step );
0 commit comments