optimizer naming updates, fixes for _impl

This commit is contained in:
Jonathan Shook
2023-12-19 00:01:28 -06:00
parent 0a4b105c3e
commit 4e9963ab17
24 changed files with 128 additions and 158 deletions

View File

@@ -29,7 +29,10 @@ public class NBJavaNativeResolver implements NBInvokableResolver {
@Override @Override
public NBInvokableCommand resolve(Cmd cmd, NBBufferedContainer parent, String phaseName) { public NBInvokableCommand resolve(Cmd cmd, NBBufferedContainer parent, String phaseName) {
return switch (cmd.getCmdType()) { return switch (cmd.getCmdType()) {
case CmdType.indirect -> NBJavaCommandLoader.init(cmd.getArgValue("_impl"), parent, phaseName, cmd.getTargetContext()); case CmdType.indirect -> {
String implName = cmd.takeArgValue("_impl");
yield NBJavaCommandLoader.init(implName, parent, phaseName, cmd.getTargetContext());
}
case CmdType.java -> NBJavaCommandLoader.init(cmd.getArgValue("class"), parent, phaseName, cmd.getTargetContext()); case CmdType.java -> NBJavaCommandLoader.init(cmd.getArgValue("class"), parent, phaseName, cmd.getTargetContext());
default -> null; default -> null;
}; };

View File

@@ -55,6 +55,12 @@ public class Cmd {
return cmdArg.getValue(); return cmdArg.getValue();
} }
public String takeArgValue(String paramName) {
String argValue = getArgValue(paramName);
this.cmdArgs.remove(paramName);
return argValue;
}
public String getArgValue(String paramName) { public String getArgValue(String paramName) {
CmdArg cmdArg = this.cmdArgs.get(paramName); CmdArg cmdArg = this.cmdArgs.get(paramName);
if (cmdArg==null) { if (cmdArg==null) {

View File

@@ -20,7 +20,7 @@ import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBCommandInfo;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBInvokableCommand; import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBInvokableCommand;
import io.nosqlbench.nb.annotations.Service; import io.nosqlbench.nb.annotations.Service;
@Service(value = NBCommandInfo.class,selector = "start") @Service(value = NBCommandInfo.class,selector = "example")
public class INFO_example extends NBCommandInfo { public class INFO_example extends NBCommandInfo {
@Override @Override
public Class<? extends NBInvokableCommand> getType() { public Class<? extends NBInvokableCommand> getType() {

View File

@@ -77,6 +77,7 @@ public class NBCommandAssembly {
throw new BasicError("Found zero commands for spec;" + cmd); throw new BasicError("Found zero commands for spec;" + cmd);
} }
String containerName = cmd.getTargetContext(); String containerName = cmd.getTargetContext();
params.remove("_impl");
parameterizedInvocations.add(new CommandInvocation(command, params, containerName)); parameterizedInvocations.add(new CommandInvocation(command, params, containerName));
} }
return parameterizedInvocations; return parameterizedInvocations;

View File

@@ -1,24 +0,0 @@
/*
* Copyright (c) 2022 nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.nosqlbench.nb;
/**
* This class is just a place holder. It holds a place.
* If only nexus understood aggregator module without src...
*/
public class PlaceHolder {
}

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.optimo; package io.nosqlbench.scenarios.simframe;
import io.nosqlbench.engine.api.activityapi.core.Activity; 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.CycleRateSpec;
@@ -28,7 +28,6 @@ import java.util.concurrent.locks.LockSupport;
public class SimFrameUtils { public class SimFrameUtils {
public static void awaitActivity(Activity flywheel) { public static void awaitActivity(Activity flywheel) {
// await flywheel actually spinning, or timeout with error // await flywheel actually spinning, or timeout with error
NBMetricTimer result_success_timer = flywheel.find().timer("name:result_success"); NBMetricTimer result_success_timer = flywheel.find().timer("name:result_success");

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax; package io.nosqlbench.scenarios.simframe.capture;
import io.nosqlbench.engine.api.activityapi.core.Activity; import io.nosqlbench.engine.api.activityapi.core.Activity;
import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetricGauge; import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetricGauge;
@@ -22,8 +22,8 @@ import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetricHistogram;
import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetricTimer; import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetricTimer;
import io.nosqlbench.scenarios.simframe.capture.SimFrameCapture; import io.nosqlbench.scenarios.simframe.capture.SimFrameCapture;
public class FindmaxFrameData extends SimFrameCapture { public class SimFrameValueData extends SimFrameCapture {
public FindmaxFrameData(Activity activity) { public SimFrameValueData(Activity activity) {
NBMetricTimer result_timer = activity.find().timer("name:result"); NBMetricTimer result_timer = activity.find().timer("name:result");
NBMetricTimer result_success_timer = activity.find().timer("name:result_success"); NBMetricTimer result_success_timer = activity.find().timer("name:result_success");
NBMetricGauge cyclerate_gauge = activity.find().gauge("name=config_cyclerate"); NBMetricGauge cyclerate_gauge = activity.find().gauge("name=config_cyclerate");
@@ -31,13 +31,13 @@ public class FindmaxFrameData extends SimFrameCapture {
NBMetricHistogram tries_histo = tries_histo_src.attachHdrDeltaHistogram(); NBMetricHistogram tries_histo = tries_histo_src.attachHdrDeltaHistogram();
addDirect("target_rate", addDirect("target_rate",
() -> cyclerate_gauge.getValue(), cyclerate_gauge::getValue,
Double.NaN); Double.NaN);
addDeltaTime("achieved_oprate", addDeltaTime("achieved_oprate",
() -> result_timer.getCount(), result_timer::getCount,
Double.NaN); Double.NaN);
addDeltaTime("achieved_ok_oprate", addDeltaTime("achieved_ok_oprate",
() -> result_success_timer.getCount() result_success_timer::getCount
, 1.0); , 1.0);
addRemix("achieved_success_ratio", vars -> { addRemix("achieved_success_ratio", vars -> {

View File

@@ -14,9 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.optimo; /**
* The types in this package are used to define observable dependent variables,
public class ThreadSpec { * specify how they are measured, formulate them into a value function, and provide
public ThreadSpec(double threads) { * a view of these over time as frames are executed.
} */
} package io.nosqlbench.scenarios.simframe.capture;

View File

@@ -1,23 +0,0 @@
/*
* Copyright (c) 2023 nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.nosqlbench.scenarios.simframe.generic;
import io.nosqlbench.engine.api.activityapi.core.Activity;
public interface ParamsEffector<P extends Record> {
P applyParams(P ptype, Activity activity);
}

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax; package io.nosqlbench.scenarios.simframe.optimizers;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBBufferedContainer; import io.nosqlbench.engine.core.lifecycle.scenario.container.NBBufferedContainer;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBBaseCommand; import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBBaseCommand;
@@ -23,8 +23,9 @@ import io.nosqlbench.engine.core.lifecycle.scenario.container.ContainerActivitie
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams; import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
import io.nosqlbench.nb.annotations.Service; import io.nosqlbench.nb.annotations.Service;
import io.nosqlbench.scenarios.simframe.capture.SimFrameCapture; import io.nosqlbench.scenarios.simframe.capture.SimFrameCapture;
import io.nosqlbench.scenarios.simframe.findmax.planners.FindmaxPlannerType; import io.nosqlbench.scenarios.simframe.capture.SimFrameValueData;
import io.nosqlbench.scenarios.simframe.optimo.SimFrameUtils; import io.nosqlbench.scenarios.simframe.optimizers.planners.OptimizerPlannerTypes;
import io.nosqlbench.scenarios.simframe.SimFrameUtils;
import io.nosqlbench.scenarios.simframe.planning.SimFramePlanner; import io.nosqlbench.scenarios.simframe.planning.SimFramePlanner;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@@ -52,11 +53,11 @@ import java.io.Reader;
* *
* <P>This can be tested as <PRE>{@code nb5 --show-stacktraces java io.nosqlbench.scenarios.findmax.SC_findmax threads=36}</PRE></P> * <P>This can be tested as <PRE>{@code nb5 --show-stacktraces java io.nosqlbench.scenarios.findmax.SC_findmax threads=36}</PRE></P>
*/ */
@Service(value = NBBaseCommand.class,selector = "findmax") @Service(value = NBBaseCommand.class,selector = "optimize")
public class NB_findmax extends NBBaseCommand { public class CMD_optimize extends NBBaseCommand {
private final static Logger logger = LogManager.getLogger(NB_findmax.class); private final static Logger logger = LogManager.getLogger(CMD_optimize.class);
public NB_findmax(NBBufferedContainer parentComponent, String scenarioName, String context) { public CMD_optimize(NBBufferedContainer parentComponent, String scenarioName, String context) {
super(parentComponent, scenarioName, context); super(parentComponent, scenarioName, context);
} }
@@ -65,9 +66,9 @@ public class NB_findmax extends NBBaseCommand {
Activity flywheel = SimFrameUtils.findFlywheelActivity(controller, params.get("activity")); Activity flywheel = SimFrameUtils.findFlywheelActivity(controller, params.get("activity"));
stdout.println("starting analysis on activity '" + flywheel.getAlias() + "'"); stdout.println("starting analysis on activity '" + flywheel.getAlias() + "'");
SimFrameUtils.awaitActivity(flywheel); SimFrameUtils.awaitActivity(flywheel);
SimFrameCapture capture = new FindmaxFrameData(flywheel); SimFrameCapture capture = new SimFrameValueData(flywheel);
String plannerType = params.getOrDefault("planner", "ratchet"); String plannerType = params.getOrDefault("planner", "ratchet");
FindmaxPlannerType plannerImpl = FindmaxPlannerType.valueOf(plannerType); OptimizerPlannerTypes plannerImpl = OptimizerPlannerTypes.valueOf(plannerType);
SimFramePlanner<?,?> planner = plannerImpl.createPlanner(params); SimFramePlanner<?,?> planner = plannerImpl.createPlanner(params);
Record result = planner.analyze(flywheel, capture, stdout, stderr, controller); Record result = planner.analyze(flywheel, capture, stdout, stderr, controller);
stdout.println("result:\n" + result); stdout.println("result:\n" + result);

View File

@@ -14,17 +14,16 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax; package io.nosqlbench.scenarios.simframe.optimizers;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBBaseCommand; import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBBaseCommand;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBCommandInfo; import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBCommandInfo;
import io.nosqlbench.nb.annotations.Service; import io.nosqlbench.nb.annotations.Service;
import io.nosqlbench.scenarios.simframe.optimo.NB_optimo;
@Service(value = NBCommandInfo.class,selector = "findmax") @Service(value = NBCommandInfo.class,selector = "optimize")
public class NBFindmaxInfo extends NBCommandInfo { public class INFO_optimize extends NBCommandInfo {
@Override @Override
public Class<? extends NBBaseCommand> getType() { public Class<? extends NBBaseCommand> getType() {
return NB_findmax.class; return CMD_optimize.class;
} }
} }

View File

@@ -14,25 +14,25 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax.planners; package io.nosqlbench.scenarios.simframe.optimizers.planners;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams; import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
import io.nosqlbench.scenarios.simframe.findmax.planners.rampup.FindmaxRampup; import io.nosqlbench.scenarios.simframe.optimizers.planners.findmax.FindmaxPlanner;
import io.nosqlbench.scenarios.simframe.findmax.planners.ratchet.FindmaxRatchet; import io.nosqlbench.scenarios.simframe.optimizers.planners.ratchet.RatchetPlanner;
import io.nosqlbench.scenarios.simframe.findmax.survey.FindmaxSurvey; import io.nosqlbench.scenarios.simframe.optimizers.planners.rcurve.RCurvePlanner;
import io.nosqlbench.scenarios.simframe.planning.SimFramePlanner; import io.nosqlbench.scenarios.simframe.planning.SimFramePlanner;
public enum FindmaxPlannerType { public enum OptimizerPlannerTypes {
// survey, // survey,
ratchet, ratchet,
rampup, findmax,
survey, rcurve,
; ;
public SimFramePlanner<?,?> createPlanner(NBCommandParams params) { public SimFramePlanner<?,?> createPlanner(NBCommandParams params) {
return switch (this) { return switch (this) {
case ratchet -> new FindmaxRatchet(params); case findmax -> new FindmaxPlanner(params);
case rampup -> new FindmaxRampup(params); case rcurve -> new RCurvePlanner(params);
case survey -> new FindmaxSurvey(params); case ratchet -> new RatchetPlanner(params);
}; };
} }
} }

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax.planners.rampup; package io.nosqlbench.scenarios.simframe.optimizers.planners.findmax;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams; import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
@@ -22,7 +22,7 @@ import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
* These search parameters are based on the original findmax algorithm, and * These search parameters are based on the original findmax algorithm, and
* should be reduced down to the minimum set needed. * should be reduced down to the minimum set needed.
*/ */
public record RampupConfig( public record FindmaxConfig(
int sample_time_ms, int sample_time_ms,
int sample_max, int sample_max,
double sample_incr, double sample_incr,
@@ -32,7 +32,7 @@ public record RampupConfig(
int average_of, int average_of,
long min_settling_ms long min_settling_ms
) { ) {
public RampupConfig(NBCommandParams params) { public FindmaxConfig(NBCommandParams params) {
this( this(
params.maybeGet("sample_time_ms").map(Integer::parseInt).orElse(4000), params.maybeGet("sample_time_ms").map(Integer::parseInt).orElse(4000),
params.maybeGet("sample_max").map(Integer::parseInt).orElse(10000), params.maybeGet("sample_max").map(Integer::parseInt).orElse(10000),

View File

@@ -14,12 +14,12 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax.planners.rampup; package io.nosqlbench.scenarios.simframe.optimizers.planners.findmax;
/** /**
* These parameters are calculated by the planner based on previous simulation frame history. * These parameters are calculated by the planner based on previous simulation frame history.
*/ */
public record RampupFrameParams( public record FindmaxFrameParams(
/** /**
* The base rate upon which we add higher deltas * The base rate upon which we add higher deltas
*/ */

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax.planners.rampup; package io.nosqlbench.scenarios.simframe.optimizers.planners.findmax;
import io.nosqlbench.engine.api.activityapi.core.Activity; 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.CycleRateSpec;
@@ -29,20 +29,20 @@ import org.apache.logging.log4j.Logger;
import java.util.Comparator; import java.util.Comparator;
public class FindmaxRampup extends SimFramePlanner<RampupConfig, RampupFrameParams> { public class FindmaxPlanner extends SimFramePlanner<FindmaxConfig, FindmaxFrameParams> {
private final Logger logger = LogManager.getLogger(FindmaxRampup.class); private final Logger logger = LogManager.getLogger(FindmaxPlanner.class);
public FindmaxRampup(NBCommandParams analyzerParams) { public FindmaxPlanner(NBCommandParams analyzerParams) {
super(analyzerParams); super(analyzerParams);
} }
@Override @Override
public RampupConfig getConfig(NBCommandParams params) { public FindmaxConfig getConfig(NBCommandParams params) {
return new RampupConfig(params); return new FindmaxConfig(params);
} }
public RampupFrameParams initialStep() { public FindmaxFrameParams initialStep() {
return new RampupFrameParams( return new FindmaxFrameParams(
config.rate_base(), config.rate_step(), config.sample_time_ms(), config.min_settling_ms(), "INITIAL" config.rate_base(), config.rate_step(), config.sample_time_ms(), config.min_settling_ms(), "INITIAL"
); );
} }
@@ -57,11 +57,11 @@ public class FindmaxRampup extends SimFramePlanner<RampupConfig, RampupFramePara
* @return Optionally, a set of paramValues which indicates another simulation frame should be sampled, else null * @return Optionally, a set of paramValues which indicates another simulation frame should be sampled, else null
*/ */
@Override @Override
public RampupFrameParams nextStep(JournalView<RampupFrameParams> journal) { public FindmaxFrameParams nextStep(JournalView<FindmaxFrameParams> journal) {
SimFrame<RampupFrameParams> last = journal.last(); SimFrame<FindmaxFrameParams> last = journal.last();
SimFrame<RampupFrameParams> best = journal.bestRun(); SimFrame<FindmaxFrameParams> best = journal.bestRun();
if (best.index() == last.index()) { // got better consecutively if (best.index() == last.index()) { // got better consecutively
return new RampupFrameParams( return new FindmaxFrameParams(
last.params().rate_shelf(), last.params().rate_shelf(),
last.params().rate_delta() * config.rate_incr(), last.params().rate_delta() * config.rate_incr(),
last.params().sample_time_ms(), last.params().sample_time_ms(),
@@ -74,7 +74,7 @@ public class FindmaxRampup extends SimFramePlanner<RampupConfig, RampupFramePara
logger.info("could not divide search space further, stop condition met"); logger.info("could not divide search space further, stop condition met");
return null; return null;
} else { } else {
return new RampupFrameParams( return new FindmaxFrameParams(
best.params().computed_rate(), best.params().computed_rate(),
config.rate_step(), config.rate_step(),
(long) (last.params().sample_time_ms() * config.sample_incr()), (long) (last.params().sample_time_ms() * config.sample_incr()),
@@ -84,13 +84,13 @@ public class FindmaxRampup extends SimFramePlanner<RampupConfig, RampupFramePara
} }
} else { // any other case } else { // any other case
// find next frame with higher rate but lower value, the closest one by rate // find next frame with higher rate but lower value, the closest one by rate
SimFrame<RampupFrameParams> nextWorseFrameWithHigherRate = journal.frames().stream() SimFrame<FindmaxFrameParams> nextWorseFrameWithHigherRate = journal.frames().stream()
.filter(f -> f.value() < best.value()) .filter(f -> f.value() < best.value())
.filter(f -> f.params().computed_rate() > best.params().computed_rate()) .filter(f -> f.params().computed_rate() > best.params().computed_rate())
.min(Comparator.comparingDouble(f -> f.params().computed_rate())) .min(Comparator.comparingDouble(f -> f.params().computed_rate()))
.orElseThrow(() -> new RuntimeException("inconsistent samples")); .orElseThrow(() -> new RuntimeException("inconsistent samples"));
if ((nextWorseFrameWithHigherRate.params().computed_rate() - best.params().computed_rate()) > config.rate_step()) { if ((nextWorseFrameWithHigherRate.params().computed_rate() - best.params().computed_rate()) > config.rate_step()) {
return new RampupFrameParams( return new FindmaxFrameParams(
best.params().computed_rate(), best.params().computed_rate(),
config.rate_step(), config.rate_step(),
(long) (last.params().sample_time_ms() * config.sample_incr()), (long) (last.params().sample_time_ms() * config.sample_incr()),
@@ -105,7 +105,7 @@ public class FindmaxRampup extends SimFramePlanner<RampupConfig, RampupFramePara
} }
@Override @Override
public void applyParams(RampupFrameParams params, Activity flywheel) { public void applyParams(FindmaxFrameParams params, Activity flywheel) {
flywheel.onEvent(ParamChange.of(new CycleRateSpec(params.rate_shelf()+params.rate_delta(), 1.1d, SimRateSpec.Verb.restart))); flywheel.onEvent(ParamChange.of(new CycleRateSpec(params.rate_shelf()+params.rate_delta(), 1.1d, SimRateSpec.Verb.restart)));
} }

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax.planners.ratchet; package io.nosqlbench.scenarios.simframe.optimizers.planners.ratchet;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams; import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;

View File

@@ -14,9 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax.planners.ratchet; package io.nosqlbench.scenarios.simframe.optimizers.planners.ratchet;
import io.nosqlbench.scenarios.simframe.planning.GenericParamModel;
public record RatchetFrameParams( public record RatchetFrameParams(
double rate, double rate,

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax.planners.ratchet; package io.nosqlbench.scenarios.simframe.optimizers.planners.ratchet;
import io.nosqlbench.engine.api.activityapi.core.Activity; 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.CycleRateSpec;
@@ -27,10 +27,10 @@ import io.nosqlbench.scenarios.simframe.planning.SimFramePlanner;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
public class FindmaxRatchet extends SimFramePlanner<RatchetConfig, RatchetFrameParams> { public class RatchetPlanner extends SimFramePlanner<RatchetConfig, RatchetFrameParams> {
private final Logger logger = LogManager.getLogger(FindmaxRatchet.class); private final Logger logger = LogManager.getLogger(RatchetPlanner.class);
public FindmaxRatchet(NBCommandParams params) { public RatchetPlanner(NBCommandParams params) {
super(params); super(params);
} }

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax.survey; package io.nosqlbench.scenarios.simframe.optimizers.planners.rcurve;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams; import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
@@ -22,15 +22,21 @@ import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
* These search parameters are based on the original findmax algorithm, and * These search parameters are based on the original findmax algorithm, and
* should be reduced down to the minimum set needed. * should be reduced down to the minimum set needed.
*/ */
public record SurveyConfig( public record RCurveConfig(
double min_rate,
double max_rate, double max_rate,
int steps int steps
) { ) {
public SurveyConfig(NBCommandParams params) { public RCurveConfig(NBCommandParams params) {
this( this(
params.maybeGet("max_rate").map(Double::parseDouble).orElse(1.2d), params.maybeGet("min_rate").map(Double::parseDouble).orElse(0.0),
params.maybeGet("steps").map(Integer::parseInt).orElse(3) params.maybeGet("max_rate").map(Double::parseDouble).orElse(10.0),
params.maybeGet("steps").map(Integer::parseInt).orElse(10)
); );
}
double rateForStep(int step) {
return min_rate + ((max_rate-min_rate)*((double)step/(double)steps));
}
} }
}

View File

@@ -14,12 +14,11 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax.survey; package io.nosqlbench.scenarios.simframe.optimizers.planners.rcurve;
public record SurveyFrameParams( public record RCurveFrameParams(
double rate, double rate,
double step, int step,
String description String description
) { ) {
} }

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package io.nosqlbench.scenarios.simframe.findmax.survey; package io.nosqlbench.scenarios.simframe.optimizers.planners.rcurve;
import io.nosqlbench.engine.api.activityapi.core.Activity; 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.CycleRateSpec;
@@ -27,21 +27,21 @@ import io.nosqlbench.scenarios.simframe.planning.SimFramePlanner;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
public class FindmaxSurvey extends SimFramePlanner<SurveyConfig, SurveyFrameParams> { public class RCurvePlanner extends SimFramePlanner<RCurveConfig, RCurveFrameParams> {
private final Logger logger = LogManager.getLogger(FindmaxSurvey.class); private final Logger logger = LogManager.getLogger(RCurvePlanner.class);
public FindmaxSurvey(NBCommandParams params) { public RCurvePlanner(NBCommandParams params) {
super(params); super(params);
} }
@Override @Override
public SurveyConfig getConfig(NBCommandParams params) { public RCurveConfig getConfig(NBCommandParams params) {
return new SurveyConfig(params); return new RCurveConfig(params);
} }
public SurveyFrameParams initialStep() { public RCurveFrameParams initialStep() {
return new SurveyFrameParams(config.max_rate(), config.steps(), "INITIAL"); return new RCurveFrameParams(config.rateForStep(1), 1, "INITIAL");
} }
/** /**
@@ -55,14 +55,18 @@ public class FindmaxSurvey extends SimFramePlanner<SurveyConfig, SurveyFramePara
*/ */
@Override @Override
public SurveyFrameParams nextStep(JournalView<SurveyFrameParams> journal) { public RCurveFrameParams nextStep(JournalView<RCurveFrameParams> journal) {
SimFrame<RCurveFrameParams> last = journal.last();
int nextStep = last.params().step() +1;
if (nextStep<=config.steps()) {
return new RCurveFrameParams(config.rateForStep(nextStep),nextStep,"Advancing to step " + nextStep);
} else {
return null; return null;
} }
}
@Override @Override
public void applyParams(SurveyFrameParams params, Activity flywheel) { public void applyParams(RCurveFrameParams params, Activity flywheel) {
flywheel.onEvent(ParamChange.of(new CycleRateSpec(params.rate(), 1.1d, SimRateSpec.Verb.restart))); flywheel.onEvent(ParamChange.of(new CycleRateSpec(params.rate(), 1.1d, SimRateSpec.Verb.restart)));
} }
} }

View File

@@ -28,9 +28,10 @@ import io.nosqlbench.engine.api.activityapi.ratelimits.simrate.CycleRateSpec;
import io.nosqlbench.engine.api.activityapi.ratelimits.simrate.SimRateSpec; import io.nosqlbench.engine.api.activityapi.ratelimits.simrate.SimRateSpec;
import io.nosqlbench.engine.core.lifecycle.scenario.container.ContainerActivitiesController; import io.nosqlbench.engine.core.lifecycle.scenario.container.ContainerActivitiesController;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams; import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
import io.nosqlbench.scenarios.simframe.SimFrameUtils;
import io.nosqlbench.scenarios.simframe.capture.SimFrameCapture; import io.nosqlbench.scenarios.simframe.capture.SimFrameCapture;
import io.nosqlbench.scenarios.simframe.capture.SimFrameJournal; import io.nosqlbench.scenarios.simframe.capture.SimFrameJournal;
import io.nosqlbench.scenarios.simframe.findmax.NB_findmax; import io.nosqlbench.scenarios.simframe.optimizers.CMD_optimize;
import io.nosqlbench.scenarios.simframe.planning.SimFrame; import io.nosqlbench.scenarios.simframe.planning.SimFrame;
import io.nosqlbench.scenarios.simframe.planning.SimFrameFunction; import io.nosqlbench.scenarios.simframe.planning.SimFrameFunction;
import io.nosqlbench.scenarios.simframe.stabilization.StatFunctions; import io.nosqlbench.scenarios.simframe.stabilization.StatFunctions;
@@ -63,7 +64,7 @@ import java.util.List;
* </OL> * </OL>
*/ */
public class NB_optimo extends NBBaseCommand { public class NB_optimo extends NBBaseCommand {
private final static Logger logger = LogManager.getLogger(NB_findmax.class); private final static Logger logger = LogManager.getLogger(CMD_optimize.class);
public NB_optimo(NBBufferedContainer parentComponent, String phaseName, String targetScenario) { public NB_optimo(NBBufferedContainer parentComponent, String phaseName, String targetScenario) {
super(parentComponent, phaseName, targetScenario); super(parentComponent, phaseName, targetScenario);