mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
adding threads option
This commit is contained in:
committed by
Jonathan Shook
parent
fc574eceb2
commit
361f441530
@@ -24,6 +24,7 @@ import io.nosqlbench.engine.core.lifecycle.scenario.container.NBBufferedContaine
|
||||
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
|
||||
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBBaseCommand;
|
||||
import io.nosqlbench.nb.api.components.events.ParamChange;
|
||||
import io.nosqlbench.nb.api.components.events.SetThreads;
|
||||
import io.nosqlbench.scenarios.simframe.SimFrameUtils;
|
||||
import io.nosqlbench.scenarios.simframe.capture.SimFrameCapture;
|
||||
import io.nosqlbench.scenarios.simframe.capture.SimFrameJournal;
|
||||
@@ -53,16 +54,30 @@ public class CMD_findmax extends NBBaseCommand {
|
||||
FindmaxParamModel model = new FindmaxParamModel();
|
||||
|
||||
FindmaxConfig findmaxConfig = new FindmaxConfig(params);
|
||||
switch(findmaxConfig.optimization_type()) {
|
||||
case "rate":
|
||||
model.add("rate",
|
||||
findmaxConfig.min_value(), // min
|
||||
findmaxConfig.base_value(), // initial
|
||||
findmaxConfig.max_value(), // max
|
||||
rate -> flywheel.onEvent(ParamChange.of(new CycleRateSpec(
|
||||
rate,
|
||||
1.1d,
|
||||
SimRateSpec.Verb.restart)))
|
||||
);
|
||||
break;
|
||||
case "threads":
|
||||
model.add("threads",
|
||||
findmaxConfig.min_value(), // min
|
||||
findmaxConfig.base_value(), // initial
|
||||
findmaxConfig.max_value(), // max
|
||||
threads -> flywheel.onEvent(ParamChange.of(new SetThreads((int) (threads))))
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported optimization type: " + findmaxConfig.optimization_type());
|
||||
}
|
||||
|
||||
model.add("rate",
|
||||
findmaxConfig.base_value(), // min
|
||||
findmaxConfig.base_value(), // initial
|
||||
findmaxConfig.sample_max(), // max
|
||||
rate -> flywheel.onEvent(ParamChange.of(new CycleRateSpec(
|
||||
rate,
|
||||
1.1d,
|
||||
SimRateSpec.Verb.restart)))
|
||||
);
|
||||
|
||||
SimFrameCapture capture = new SimFrameValueData(flywheel);
|
||||
FindmaxFrameFunction frameFunction = new FindmaxFrameFunction(controller, findmaxConfig, flywheel, capture, journal, model);
|
||||
|
||||
@@ -20,25 +20,31 @@ import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
|
||||
|
||||
public class FindmaxConfig {
|
||||
private double sample_time_ms;
|
||||
private double sample_max;
|
||||
private double max_value;
|
||||
private double base_value;
|
||||
private double min_value;
|
||||
private double step_value;
|
||||
private double value_incr;
|
||||
private double sample_incr;
|
||||
private long min_settling_ms;
|
||||
private String optimization_type;
|
||||
|
||||
public double sample_time_ms() {
|
||||
return sample_time_ms;
|
||||
}
|
||||
|
||||
public double sample_max() {
|
||||
return sample_max;
|
||||
public double max_value() {
|
||||
return max_value;
|
||||
}
|
||||
|
||||
public double base_value() {
|
||||
return base_value;
|
||||
}
|
||||
|
||||
public double min_value() {
|
||||
return min_value;
|
||||
}
|
||||
|
||||
public double step_value() {
|
||||
return step_value;
|
||||
}
|
||||
@@ -55,12 +61,16 @@ public class FindmaxConfig {
|
||||
return min_settling_ms;
|
||||
}
|
||||
|
||||
public String optimization_type() {
|
||||
return optimization_type;
|
||||
}
|
||||
|
||||
public void setSample_time_ms(double sample_time_ms) {
|
||||
this.sample_time_ms = sample_time_ms;
|
||||
}
|
||||
|
||||
public void setSample_max(double sample_max) {
|
||||
this.sample_max = sample_max;
|
||||
public void setMax_value(double max_value) {
|
||||
this.max_value = max_value;
|
||||
}
|
||||
|
||||
public void setBase_value(double base_value) {
|
||||
@@ -71,6 +81,10 @@ public class FindmaxConfig {
|
||||
this.step_value = step_value;
|
||||
}
|
||||
|
||||
public void setMin_value(double min_value) {
|
||||
this.min_value = min_value;
|
||||
}
|
||||
|
||||
public void setSample_incr(double sample_incr) {
|
||||
this.sample_incr = sample_incr;
|
||||
}
|
||||
@@ -83,13 +97,19 @@ public class FindmaxConfig {
|
||||
this.min_settling_ms = min_settling_ms;
|
||||
}
|
||||
|
||||
public void setOptimization_type(String optimization_type) {
|
||||
this.optimization_type = optimization_type;
|
||||
}
|
||||
|
||||
public FindmaxConfig(NBCommandParams params) {
|
||||
setSample_time_ms(params.maybeGet("sample_time_ms").map(Double::parseDouble).orElse(4000d));
|
||||
setSample_max(params.maybeGet("sample_max").map(Double::parseDouble).orElse(10000d));
|
||||
setMax_value(params.maybeGet("max_value").map(Double::parseDouble).orElse(10000d));
|
||||
setBase_value(params.maybeGet("base_value").map(Double::parseDouble).orElse(10d));
|
||||
setMin_value(params.maybeGet("min_value").map(Double::parseDouble).orElse(0d));
|
||||
setStep_value(params.maybeGet("step_value").map(Double::parseDouble).orElse(100d));
|
||||
setValue_incr(params.maybeGet("value_incr").map(Double::parseDouble).orElse(2d));
|
||||
setSample_incr(params.maybeGet("sample_incr").map(Double::parseDouble).orElse(1.2d));
|
||||
setMin_settling_ms(params.maybeGet("min_settling_ms").map(Long::parseLong).orElse(4000L));
|
||||
setOptimization_type(params.maybeGet("optimization_type").orElse("rate"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,11 +75,11 @@ public class FindmaxFrameFunction implements SimFrameFunction {
|
||||
}
|
||||
|
||||
public double nextStep() {
|
||||
double newRate;
|
||||
double newValue;
|
||||
SimFrame<FindmaxFrameParams> last = journal.last();
|
||||
SimFrame<FindmaxFrameParams> best = journal.bestRun();
|
||||
if (best.index() == last.index()) { // got better consecutively
|
||||
newRate = last.params().paramValues()[0] + settings.step_value();
|
||||
newValue = last.params().paramValues()[0] + settings.step_value();
|
||||
settings.setStep_value(settings.step_value() * settings.value_incr());
|
||||
} else if (best.index() == last.index() - 1) {
|
||||
// got worse consecutively, this may be collapsed out since the general case below covers it (test first)
|
||||
@@ -88,7 +88,7 @@ public class FindmaxFrameFunction implements SimFrameFunction {
|
||||
logger.info("could not divide search space further, stop condition met");
|
||||
return 0;
|
||||
} else {
|
||||
newRate = best.params().paramValues()[0] + settings.step_value();
|
||||
newValue = best.params().paramValues()[0] + settings.step_value();
|
||||
settings.setSample_time_ms(settings.sample_time_ms() * settings.sample_incr());
|
||||
settings.setMin_settling_ms(settings.min_settling_ms() * 4);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class FindmaxFrameFunction implements SimFrameFunction {
|
||||
.orElseThrow(() -> new RuntimeException("inconsistent samples"));
|
||||
if ((nextWorseFrameWithHigherRate.params().paramValues()[0] + settings.step_value() -
|
||||
best.params().paramValues()[0] + settings.step_value()) > settings.step_value()) {
|
||||
newRate = best.params().paramValues()[0] + settings.step_value();
|
||||
newValue = best.params().paramValues()[0] + settings.step_value();
|
||||
settings.setSample_time_ms(settings.sample_time_ms() * settings.sample_incr());
|
||||
settings.setMin_settling_ms(settings.min_settling_ms() * 2);
|
||||
} else {
|
||||
@@ -109,7 +109,7 @@ public class FindmaxFrameFunction implements SimFrameFunction {
|
||||
return 0.0d;
|
||||
}
|
||||
}
|
||||
double[] point = {newRate};
|
||||
double[] point = {newValue};
|
||||
return value(point);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user