engine and runtime updates for vector branch

This commit is contained in:
Jonathan Shook
2023-07-25 11:50:28 -05:00
parent ad58a7959a
commit 23aba88ee0
10 changed files with 2152 additions and 28 deletions

View File

@@ -16,7 +16,7 @@
package io.nosqlbench.engine.cli; package io.nosqlbench.engine.cli;
import io.nosqlbench.engine.api.templating.StrInterpolator; import io.nosqlbench.adapters.api.templating.StrInterpolator;
import io.nosqlbench.api.content.Content; import io.nosqlbench.api.content.Content;
import io.nosqlbench.api.content.NBIO; import io.nosqlbench.api.content.NBIO;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;

View File

@@ -32,7 +32,7 @@ import io.nosqlbench.engine.api.activityapi.cyclelog.outputs.cyclelog.CycleLogDu
import io.nosqlbench.engine.api.activityapi.cyclelog.outputs.cyclelog.CycleLogImporterUtility; import io.nosqlbench.engine.api.activityapi.cyclelog.outputs.cyclelog.CycleLogImporterUtility;
import io.nosqlbench.engine.api.activityapi.input.InputType; import io.nosqlbench.engine.api.activityapi.input.InputType;
import io.nosqlbench.engine.api.activityapi.output.OutputType; import io.nosqlbench.engine.api.activityapi.output.OutputType;
import io.nosqlbench.engine.api.activityconfig.rawyaml.RawOpsLoader; import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpsLoader;
import io.nosqlbench.engine.cli.NBCLIOptions.LoggerConfigData; import io.nosqlbench.engine.cli.NBCLIOptions.LoggerConfigData;
import io.nosqlbench.engine.cli.NBCLIOptions.Mode; import io.nosqlbench.engine.cli.NBCLIOptions.Mode;
import io.nosqlbench.engine.core.annotation.Annotators; import io.nosqlbench.engine.core.annotation.Annotators;

View File

@@ -16,9 +16,9 @@
package io.nosqlbench.engine.cli; package io.nosqlbench.engine.cli;
import io.nosqlbench.engine.api.activityconfig.OpsLoader; import io.nosqlbench.adapters.api.activityconfig.OpsLoader;
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate; import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplate;
import io.nosqlbench.engine.api.activityconfig.yaml.OpsDocList; import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDocList;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.List; import java.util.List;

View File

@@ -15,11 +15,12 @@
*/ */
package io.nosqlbench.engine.core.lifecycle.activity; package io.nosqlbench.engine.core.lifecycle.activity;
import io.nosqlbench.engine.api.activityapi.core.*;
import io.nosqlbench.engine.api.activityimpl.MotorState;
import io.nosqlbench.api.annotations.Annotation; import io.nosqlbench.api.annotations.Annotation;
import io.nosqlbench.api.annotations.Layer; import io.nosqlbench.api.annotations.Layer;
import io.nosqlbench.api.engine.activityimpl.ActivityDef; import io.nosqlbench.api.engine.activityimpl.ActivityDef;
import io.nosqlbench.api.engine.activityimpl.ParameterMap; import io.nosqlbench.api.engine.activityimpl.ParameterMap;
import io.nosqlbench.engine.api.activityapi.core.*;
import io.nosqlbench.engine.api.activityapi.core.progress.ProgressCapable; import io.nosqlbench.engine.api.activityapi.core.progress.ProgressCapable;
import io.nosqlbench.engine.api.activityapi.core.progress.ProgressMeterDisplay; import io.nosqlbench.engine.api.activityapi.core.progress.ProgressMeterDisplay;
import io.nosqlbench.engine.api.activityimpl.motor.RunStateImage; import io.nosqlbench.engine.api.activityimpl.motor.RunStateImage;
@@ -41,7 +42,7 @@ import java.util.stream.Collectors;
* *
* <p>In order to allow for dynamic thread management, which is not easily supported as an explicit feature * <p>In order to allow for dynamic thread management, which is not easily supported as an explicit feature
* of most executor services, threads are started as long-running processes and managed via state signaling. * of most executor services, threads are started as long-running processes and managed via state signaling.
* The {@link RunState} enum, {@link io.nosqlbench.engine.api.activityimpl.MotorState} type, and {@link RunStateTally} * The {@link RunState} enum, {@link MotorState} type, and {@link RunStateTally}
* state tracking class are used together to represent valid states and transitions, contain and transition state atomically, * state tracking class are used together to represent valid states and transitions, contain and transition state atomically,
* and provide blocking conditions for observers, respectively.</p> * and provide blocking conditions for observers, respectively.</p>
* *

View File

@@ -19,7 +19,7 @@ package io.nosqlbench.engine.core.lifecycle.activity;
import io.nosqlbench.api.config.NBLabeledElement; import io.nosqlbench.api.config.NBLabeledElement;
import io.nosqlbench.engine.api.activityapi.core.ActivityType; import io.nosqlbench.engine.api.activityapi.core.ActivityType;
import io.nosqlbench.api.engine.activityimpl.ActivityDef; import io.nosqlbench.api.engine.activityimpl.ActivityDef;
import io.nosqlbench.engine.api.activityimpl.uniform.DriverAdapter; import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.engine.api.activityimpl.uniform.StandardActivityType; import io.nosqlbench.engine.api.activityimpl.uniform.StandardActivityType;
import io.nosqlbench.nb.annotations.Maturity; import io.nosqlbench.nb.annotations.Maturity;
import io.nosqlbench.api.system.NBEnvironment; import io.nosqlbench.api.system.NBEnvironment;

View File

@@ -139,10 +139,10 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
} }
public static Scenario forTesting(final String name, final Engine engine, final String reportSummaryTo, final Maturity minMaturity) { public static Scenario forTesting(final String name, final Engine engine, final String reportSummaryTo, final Maturity minMaturity) {
return new Scenario(name,null,engine,"console:10s",true,true,reportSummaryTo,"",Path.of("logs"),minMaturity, NBLabeledElement.forKV("test-name","name")); return new Scenario(name, null, engine, "console:10s", true, true, reportSummaryTo, "", Path.of("logs"), minMaturity, NBLabeledElement.forKV("test-name", "name"));
} }
// public Scenario(final String name, final Engine engine, final String reportSummaryTo, final Maturity minMaturity) { // public Scenario(final String name, final Engine engine, final String reportSummaryTo, final Maturity minMaturity) {
// scenarioName = name; // scenarioName = name;
// this.reportSummaryTo = reportSummaryTo; // this.reportSummaryTo = reportSummaryTo;
// this.engine = engine; // this.engine = engine;
@@ -199,8 +199,8 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
.allowAllAccess(true) .allowAllAccess(true)
.allowEnvironmentAccess(EnvironmentAccess.INHERIT) .allowEnvironmentAccess(EnvironmentAccess.INHERIT)
.allowPolyglotAccess(PolyglotAccess.ALL) .allowPolyglotAccess(PolyglotAccess.ALL)
.option("js.ecmascript-version", "2020") .option("js.ecmascript-version", "2022")
.option("js.nashorn-compat", "true"); .option("js.nashorn-compat", "false");
final Builder engineBuilder = org.graalvm.polyglot.Engine.newBuilder(); final Builder engineBuilder = org.graalvm.polyglot.Engine.newBuilder();
engineBuilder.option("engine.WarnInterpreterOnly", "false"); engineBuilder.option("engine.WarnInterpreterOnly", "false");
@@ -213,15 +213,10 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
if (!"disabled".equals(progressInterval)) if (!"disabled".equals(progressInterval))
this.activityProgressIndicator = new ActivityProgressIndicator(scenarioController, this.progressInterval); this.activityProgressIndicator = new ActivityProgressIndicator(scenarioController, this.progressInterval);
this.scriptEnv = new ScenarioContext(scenarioName,scenarioController); this.scriptEnv = new ScenarioContext(scenarioName, scenarioController);
this.scriptEngine.setContext(this.scriptEnv); this.scriptEngine.setContext(this.scriptEnv);
this.scriptEngine.put("params", this.scenarioScriptParams); this.scriptEngine.put("params", this.scenarioScriptParams);
// scriptEngine.put("scenario", scenarioController);
// scriptEngine.put("metrics", new PolyglotMetricRegistryBindings(metricRegistry));
// scriptEngine.put("activities", new NashornActivityBindings(scenarioController));
this.scriptEngine.put("scenario", new PolyglotScenarioController(scenarioController)); this.scriptEngine.put("scenario", new PolyglotScenarioController(scenarioController));
this.scriptEngine.put("metrics", new PolyglotMetricRegistryBindings(metricRegistry)); this.scriptEngine.put("metrics", new PolyglotMetricRegistryBindings(metricRegistry));
this.scriptEngine.put("activities", new ActivityBindings(scenarioController)); this.scriptEngine.put("activities", new ActivityBindings(scenarioController));
@@ -280,7 +275,7 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
this.logger.debug("Awaiting completion of scenario and activities for {} millis.", awaitCompletionTime); this.logger.debug("Awaiting completion of scenario and activities for {} millis.", awaitCompletionTime);
this.scenarioController.awaitCompletion(awaitCompletionTime); this.scenarioController.awaitCompletion(awaitCompletionTime);
} catch (final Exception e) { } catch (final Exception e) {
error =e; error = e;
} finally { } finally {
this.scenarioController.shutdown(); this.scenarioController.shutdown();
} }
@@ -293,8 +288,9 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
} }
public void notifyException(final Thread t, final Throwable e) { public void notifyException(final Thread t, final Throwable e) {
error =new RuntimeException("in thread " + t.getName() + ", " +e, e); error = new RuntimeException("in thread " + t.getName() + ", " + e, e);
} }
private void executeScenarioScripts() { private void executeScenarioScripts() {
for (final String script : this.scripts) for (final String script : this.scripts)
try { try {
@@ -383,13 +379,13 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
/** /**
* This should be the only way to get a ScenarioResult for a Scenario. * This should be the only way to get a ScenarioResult for a Scenario.
* * <p>
* The lifecycle of a scenario includes the lifecycles of all of the following: * The lifecycle of a scenario includes the lifecycles of all of the following:
* <OL> * <OL>
* <LI>The scenario control script, executing within a graaljs context.</LI> * <LI>The scenario control script, executing within a graaljs context.</LI>
* <LI>The lifecycle of every activity which is started within the scenario.</LI> * <LI>The lifecycle of every activity which is started within the scenario.</LI>
* </OL> * </OL>
* * <p>
* All of these run asynchronously within the scenario, however the same thread that calls * All of these run asynchronously within the scenario, however the same thread that calls
* the scenario is the one which executes the control script. A scenario ends when all * the scenario is the one which executes the control script. A scenario ends when all
* of the following conditions are met: * of the following conditions are met:
@@ -406,12 +402,14 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
try { try {
this.runScenario(); this.runScenario();
} catch (final Exception e) { } catch (final Exception e) {
error =e; error = e;
} finally { } finally {
this.logger.debug("{} scenario run", null == this.error ? "NORMAL" : "ERRORED"); this.logger.debug("{} scenario run", null == this.error ? "NORMAL" : "ERRORED");
} }
if (this.scriptEnv == null) {
final String iolog = this.scriptEnv.getTimedLog(); }
String iolog = error != null ? error.toString() : this.scriptEnv.getTimedLog();
result = new ExecutionMetricsResult(startedAtMillis, endedAtMillis, iolog, this.error); result = new ExecutionMetricsResult(startedAtMillis, endedAtMillis, iolog, this.error);
this.result.reportMetricsSummaryToLog(); this.result.reportMetricsSummaryToLog();
this.doReportSummaries(this.reportSummaryTo, this.result); this.doReportSummaries(this.reportSummaryTo, this.result);

View File

@@ -80,9 +80,9 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId> <artifactId>groovy</artifactId>
<version>3.0.14</version> <version>4.0.13</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -352,7 +352,7 @@
<dependency> <dependency>
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId> <artifactId>antlr4-runtime</artifactId>
<version>4.12.0</version> <version>4.13.0</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -734,6 +734,7 @@
</includes> </includes>
<excludes> <excludes>
<exclude>**/generated/**</exclude> <exclude>**/generated/**</exclude>
<exclude>**/jmh_generated/**</exclude>
</excludes> </excludes>
<addLicenseHeaders>true</addLicenseHeaders> <addLicenseHeaders>true</addLicenseHeaders>
<copyrightMessage>Copyright (c) 2022 nosqlbench</copyrightMessage> <copyrightMessage>Copyright (c) 2022 nosqlbench</copyrightMessage>
@@ -812,7 +813,7 @@
<plugin> <plugin>
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId> <artifactId>antlr4-maven-plugin</artifactId>
<version>4.12.0</version> <version>4.13.0</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>

View File

@@ -0,0 +1,7 @@
scenarios:
default:
vectors: run driver=stdout cycles=10 threads=1 format=readout
bindings:
hfv768raw: HashedFloatVectors(768); Stringify();
hfv768cql: HashedFloatVectors(768); ToCqlVector();

View File

@@ -0,0 +1,53 @@
scenarios:
default:
vectors: run driver=stdout cycles=10 threads=1 format=readout
bindings:
# create double and float vectors which high dispersion across the number
# of dimensions specified. These are not yet enumerable, but they are
# deterministic
hdv1: HashedDoubleVectors(13); Stringify();
hfv1: HashedFloatVectors(13); Stringify();
# specify the sizer function and the double function
hdvn2: HashedDoubleVectors(long->HashRange(1,5)->int,long->HashRange(2.0d,3.0d)->double); NormalizeDoubleVector(); Stringify();
# specify the sizer function and the range of doubles to use
hdv3: HashedDoubleVectors(long->HashRange(1,5)->int,long->HashRange(2.0d,3.0d)->double); Stringify();
hdv4: HashedDoubleVectors(13,0.0d,1.0d); Stringify();
hfv4: HashedFloatVectors(13,0.0f,1.0f); Stringify();
# create a simple 2-d vector from a step function over the unit interval
# of 10 steps (the maximum number of characters per digit)
v2d: DoubleVectors('0-2*2')
# use Stringify() to visualize the value of numeric array types
v2d_str: DoubleVectors('0-2*2'); Stringify()
# normalize!
v2dn: DoubleVectors('0-2*2'); NormalizeDoubleVector();
# normalize and stringify
v2dn_str: DoubleVectors('0-2*2'); NormalizeDoubleVector(); Stringify();
# create a double vector based on 10 values per digit, by 10 digits.
# this determines that the step function should be 0.1 per step, wrapping,
# then maps this to a combinitoric model based on charset cardinality
v1d: DoubleVectors('0-9*10');
v1dn: DoubleVectors('0-9*10'); NormalizeDoubleVector();
v1d_str: DoubleVectors('0-9*10'); Stringify();
v1dn_str: DoubleVectors('0-9*10'); NormalizeDoubleVector(); Stringify();
v1d_cql: DoubleVectors('0-9*10'); ToCqlVector();
v_09_10f: FloatVectors('0-9*10');
unit_v_f_n: FloatVectors('0-9*10'); NormalizeFloatVector();
v_az_3: DoubleVectors('a-z*3');
unit_v_d_n: DoubleVectors('a-z*5'); NormalizeDoubleVector();