partial working optimo, something is still broken in the search behavior

This commit is contained in:
Jonathan Shook
2023-10-10 00:28:05 -05:00
parent 6b85515715
commit e64de7476e
18 changed files with 381 additions and 118 deletions

View File

@@ -84,7 +84,10 @@ public class PerfWindowSampler {
double[] vals = data[window][measuredItem];
if (criteria.get(measuredItem).delta) {
return (vals[ENDS] - vals[STARTS]) / (vals[END_TIME] - vals[START_TIME])*1000.0d;
double duration = (vals[END_TIME] - vals[START_TIME])/1000D;
double increment = vals[ENDS] - vals[STARTS];
return increment / duration;
} else {
return vals[ENDS];
}

View File

@@ -24,7 +24,11 @@ import io.nosqlbench.api.engine.metrics.instruments.NBMetricTimer;
import io.nosqlbench.api.optimizers.BobyqaOptimizerInstance;
import io.nosqlbench.api.optimizers.MVResult;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.components.events.ParamChange;
import io.nosqlbench.engine.api.activityapi.core.Activity;
import io.nosqlbench.engine.api.activityapi.ratelimits.simrate.CycleRateSpec;
import io.nosqlbench.engine.api.activityapi.ratelimits.simrate.SimRate;
import io.nosqlbench.engine.api.activityapi.ratelimits.simrate.SimRateSpec;
import io.nosqlbench.engine.core.lifecycle.scenario.direct.SCBaseScenario;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -51,7 +55,8 @@ public class SC_optimo extends SCBaseScenario {
"cycles", String.valueOf(Long.MAX_VALUE),
"threads", "1",
"driver", "diag",
"rate", "1"
"rate", "1",
"dryrun","op"
));
if (params.containsKey("workload")) {
activityParams.put("workload", params.get("workload"));
@@ -67,13 +72,13 @@ public class SC_optimo extends SCBaseScenario {
BobyqaOptimizerInstance bobby = create().bobyqaOptimizer();
bobby.param("rate", 1.0d, 10000.d);
bobby.param("threads", 1.0d, 1000.0d);
bobby.setInitialRadius(10000.0).setStoppingRadius(0.001).setMaxEval(1000);
bobby.param("noise", 100d, 200.0d);
bobby.setInitialRadius(1000000.0).setStoppingRadius(0.001).setMaxEval(1000);
Activity flywheel = controller.start(activityParams);
stdout.println("warming up for " + seconds + " seconds");
controller.waitMillis(5000);
/**
* <P>This function is the objective function, and is responsible for applying
* the parameters and yielding a result. The higher the returned result, the
@@ -83,38 +88,38 @@ public class SC_optimo extends SCBaseScenario {
PerfWindowSampler sampler = new PerfWindowSampler();
NBMetricTimer result_success_timer = flywheel.find().timer("name:result_success");
sampler.addDeltaTime("achieved_rate", result_success_timer::getCount, 1.0);
sampler.addDeltaTime("achieved_rate", result_success_timer::getCount, 1000.0);
final DeltaSnapshotReader snapshotter = result_success_timer.getDeltaReader();
AtomicReference<ConvenientSnapshot> snapshot = new AtomicReference<>(snapshotter.getDeltaSnapshot());
ValidAtOrBelow below15000 = ValidAtOrBelow.max(15000);
sampler.addDirect(
"p99latency",
() -> below15000.applyAsDouble(snapshot.get().getP99ns()),
-1.0,
() -> snapshot.set(snapshotter.getDeltaSnapshot())
);
// ValidAtOrBelow below15000 = ValidAtOrBelow.max(15000);
// sampler.addDirect(
// "p99latency",
// () -> below15000.applyAsDouble(snapshot.get().getP99ns()),
// -1.0,
// () -> snapshot.set(snapshotter.getDeltaSnapshot())
// );
sampler.startWindow();
ToDoubleFunction<double[]> f = new ToDoubleFunction<double[]>() {
@Override
public double applyAsDouble(double[] values) {
stdout.println("params=" + Arrays.toString(values));
int threads = (int) bobby.getParams().getValue("threads", values);
double rate = bobby.getParams().getValue("rate", values);
stdout.println("setting threads to " + threads);
int threads = (int) bobby.getParams().getValue("threads", values);
stdout.println("SETTING threads to " + threads);
flywheel.getActivityDef().setThreads(threads);
String ratespec = rate + ":1.1:restart";
stdout.println("setting rate to " + ratespec);
flywheel.getActivityDef().getParams().put("rate", ratespec);
double rate = bobby.getParams().getValue("rate", values);
stdout.println("SETTING rate to "+ rate);
CycleRateSpec ratespec = new CycleRateSpec(rate, 1.1d, SimRateSpec.Verb.restart);
flywheel.onEvent(new ParamChange<>(ratespec));
sampler.startWindow();
stdout.println("waiting " + seconds + " seconds...");
controller.waitMillis(seconds * 1000L);
sampler.stopWindow();
double value = sampler.getCurrentWindowValue();
stdout.println(sampler.toString());
stdout.println("RESULT: " + sampler);
return value;
}