mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
partial improvements
This commit is contained in:
@@ -17,19 +17,22 @@
|
|||||||
package io.nosqlbench.scenarios.simframe.findmax.planners;
|
package io.nosqlbench.scenarios.simframe.findmax.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.findmax.planners.ratchet.FindmaxRatchet;
|
import io.nosqlbench.scenarios.simframe.findmax.planners.ratchet.FindmaxRatchet;
|
||||||
|
import io.nosqlbench.scenarios.simframe.findmax.survey.FindmaxSurvey;
|
||||||
import io.nosqlbench.scenarios.simframe.planning.SimFramePlanner;
|
import io.nosqlbench.scenarios.simframe.planning.SimFramePlanner;
|
||||||
|
|
||||||
public enum FindmaxPlannerType {
|
public enum FindmaxPlannerType {
|
||||||
// survey,
|
// survey,
|
||||||
ratchet,
|
ratchet,
|
||||||
rampup;
|
rampup,
|
||||||
|
survey,
|
||||||
;
|
;
|
||||||
public SimFramePlanner<?,?> createPlanner(NBCommandParams params) {
|
public SimFramePlanner<?,?> createPlanner(NBCommandParams params) {
|
||||||
return switch (this) {
|
return switch (this) {
|
||||||
case ratchet -> new FindmaxRatchet(params);
|
case ratchet -> new FindmaxRatchet(params);
|
||||||
// case survey -> new FindmaxSurvey(params);
|
|
||||||
case rampup -> new FindmaxRampup(params);
|
case rampup -> new FindmaxRampup(params);
|
||||||
|
case survey -> new FindmaxSurvey(params);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.nosqlbench.scenarios.simframe.findmax.planners;
|
package io.nosqlbench.scenarios.simframe.findmax.planners.rampup;
|
||||||
|
|
||||||
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;
|
||||||
@@ -22,8 +22,6 @@ import io.nosqlbench.engine.api.activityapi.ratelimits.simrate.SimRateSpec;
|
|||||||
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
|
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
|
||||||
import io.nosqlbench.nb.api.components.events.ParamChange;
|
import io.nosqlbench.nb.api.components.events.ParamChange;
|
||||||
import io.nosqlbench.scenarios.simframe.capture.JournalView;
|
import io.nosqlbench.scenarios.simframe.capture.JournalView;
|
||||||
import io.nosqlbench.scenarios.simframe.findmax.FindMaxFrameParams;
|
|
||||||
import io.nosqlbench.scenarios.simframe.findmax.FindmaxSearchParams;
|
|
||||||
import io.nosqlbench.scenarios.simframe.planning.SimFrame;
|
import io.nosqlbench.scenarios.simframe.planning.SimFrame;
|
||||||
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;
|
||||||
@@ -31,7 +29,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
public class FindmaxRampup extends SimFramePlanner<FindmaxSearchParams, FindMaxFrameParams> {
|
public class FindmaxRampup extends SimFramePlanner<RampupConfig, RampupFrameParams> {
|
||||||
private final Logger logger = LogManager.getLogger(FindmaxRampup.class);
|
private final Logger logger = LogManager.getLogger(FindmaxRampup.class);
|
||||||
|
|
||||||
public FindmaxRampup(NBCommandParams analyzerParams) {
|
public FindmaxRampup(NBCommandParams analyzerParams) {
|
||||||
@@ -39,12 +37,12 @@ public class FindmaxRampup extends SimFramePlanner<FindmaxSearchParams, FindMaxF
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FindmaxSearchParams getConfig(NBCommandParams params) {
|
public RampupConfig getConfig(NBCommandParams params) {
|
||||||
return new FindmaxSearchParams(params);
|
return new RampupConfig(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindMaxFrameParams initialStep() {
|
public RampupFrameParams initialStep() {
|
||||||
return new FindMaxFrameParams(
|
return new RampupFrameParams(
|
||||||
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"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -59,11 +57,11 @@ public class FindmaxRampup extends SimFramePlanner<FindmaxSearchParams, FindMaxF
|
|||||||
* @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 FindMaxFrameParams nextStep(JournalView<FindMaxFrameParams> journal) {
|
public RampupFrameParams nextStep(JournalView<RampupFrameParams> journal) {
|
||||||
SimFrame<FindMaxFrameParams> last = journal.last();
|
SimFrame<RampupFrameParams> last = journal.last();
|
||||||
SimFrame<FindMaxFrameParams> best = journal.bestRun();
|
SimFrame<RampupFrameParams> best = journal.bestRun();
|
||||||
if (best.index() == last.index()) { // got better consecutively
|
if (best.index() == last.index()) { // got better consecutively
|
||||||
return new FindMaxFrameParams(
|
return new RampupFrameParams(
|
||||||
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(),
|
||||||
@@ -76,7 +74,7 @@ public class FindmaxRampup extends SimFramePlanner<FindmaxSearchParams, FindMaxF
|
|||||||
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 FindMaxFrameParams(
|
return new RampupFrameParams(
|
||||||
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()),
|
||||||
@@ -86,13 +84,13 @@ public class FindmaxRampup extends SimFramePlanner<FindmaxSearchParams, FindMaxF
|
|||||||
}
|
}
|
||||||
} 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<FindMaxFrameParams> nextWorseFrameWithHigherRate = journal.frames().stream()
|
SimFrame<RampupFrameParams> 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 FindMaxFrameParams(
|
return new RampupFrameParams(
|
||||||
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()),
|
||||||
@@ -107,7 +105,7 @@ public class FindmaxRampup extends SimFramePlanner<FindmaxSearchParams, FindMaxF
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyParams(FindMaxFrameParams params, Activity flywheel) {
|
public void applyParams(RampupFrameParams 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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.nosqlbench.scenarios.simframe.findmax;
|
package io.nosqlbench.scenarios.simframe.findmax.planners.rampup;
|
||||||
|
|
||||||
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 FindmaxSearchParams(
|
public record RampupConfig(
|
||||||
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 FindmaxSearchParams(
|
|||||||
int average_of,
|
int average_of,
|
||||||
long min_settling_ms
|
long min_settling_ms
|
||||||
) {
|
) {
|
||||||
public FindmaxSearchParams(NBCommandParams params) {
|
public RampupConfig(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),
|
||||||
@@ -14,12 +14,12 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.nosqlbench.scenarios.simframe.findmax;
|
package io.nosqlbench.scenarios.simframe.findmax.planners.rampup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 FindMaxFrameParams(
|
public record RampupFrameParams(
|
||||||
/**
|
/**
|
||||||
* The base rate upon which we add higher deltas
|
* The base rate upon which we add higher deltas
|
||||||
*/
|
*/
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* 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.findmax.survey;
|
||||||
|
|
||||||
|
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.SimRateSpec;
|
||||||
|
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
|
||||||
|
import io.nosqlbench.nb.api.components.events.ParamChange;
|
||||||
|
import io.nosqlbench.scenarios.simframe.capture.JournalView;
|
||||||
|
import io.nosqlbench.scenarios.simframe.planning.SimFrame;
|
||||||
|
import io.nosqlbench.scenarios.simframe.planning.SimFramePlanner;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
public class FindmaxSurvey extends SimFramePlanner<SurveyConfig, SurveyFrameParams> {
|
||||||
|
private final Logger logger = LogManager.getLogger(FindmaxSurvey.class);
|
||||||
|
|
||||||
|
public FindmaxSurvey(NBCommandParams params) {
|
||||||
|
super(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SurveyConfig getConfig(NBCommandParams params) {
|
||||||
|
return new SurveyConfig(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SurveyFrameParams initialStep() {
|
||||||
|
return new SurveyFrameParams(config.max_rate(), config.steps(), "INITIAL");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Using a stateful history of all control parameters and all results, decide if there
|
||||||
|
* is additional search space and return a set of parameters for the next workload
|
||||||
|
* simulation frame. If the stopping condition has been met, return null
|
||||||
|
*
|
||||||
|
* @param journal
|
||||||
|
* All parameters and results, organized in enumerated simulation frames
|
||||||
|
* @return Optionally, a set of paramValues which indicates another simulation frame should be sampled, else null
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SurveyFrameParams nextStep(JournalView<SurveyFrameParams> journal) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyParams(SurveyFrameParams params, Activity flywheel) {
|
||||||
|
flywheel.onEvent(ParamChange.of(new CycleRateSpec(params.rate(), 1.1d, SimRateSpec.Verb.restart)));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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.findmax.survey;
|
||||||
|
|
||||||
|
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These search parameters are based on the original findmax algorithm, and
|
||||||
|
* should be reduced down to the minimum set needed.
|
||||||
|
*/
|
||||||
|
public record SurveyConfig(
|
||||||
|
double max_rate,
|
||||||
|
int steps
|
||||||
|
) {
|
||||||
|
public SurveyConfig(NBCommandParams params) {
|
||||||
|
this(
|
||||||
|
params.maybeGet("max_rate").map(Double::parseDouble).orElse(1.2d),
|
||||||
|
params.maybeGet("steps").map(Integer::parseInt).orElse(3)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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.findmax.survey;
|
||||||
|
|
||||||
|
public record SurveyFrameParams(
|
||||||
|
double rate,
|
||||||
|
double step,
|
||||||
|
String description
|
||||||
|
|
||||||
|
) {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user