added hdr histo logging builder

This commit is contained in:
Mark Wolters 2023-10-05 13:16:22 -04:00 committed by Jonathan Shook
parent dc06437d6e
commit bfd15818f9
15 changed files with 66 additions and 175 deletions

View File

@ -1,38 +0,0 @@
/*
* Copyright (c) 2022-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.engine.extensions.files;
import io.nosqlbench.api.config.LabeledScenarioContext;
import io.nosqlbench.api.extensions.ScriptingExtensionPluginInfo;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nb.annotations.Service;
import org.apache.logging.log4j.Logger;
@Service(value = ScriptingExtensionPluginInfo.class, selector = "files")
public class FileAccessPluginData implements ScriptingExtensionPluginInfo<FileAccess> {
@Override
public String getDescription() {
return "Allows for convenient read access to local files";
}
@Override
public FileAccess getExtensionObject(final Logger logger, final NBComponent baseComponent) {
return new FileAccess();
}
}

View File

@ -1,18 +0,0 @@
fileaccess extension
====================
This extension makes it easy to load the contents of a file
into a string variable in your scripting environment.
### Example
~~~
var content = files.read("somefile.txt");
~~~
The file is located through the nosqlbench file loader, which means
that it will be loaded as:
1) a URL, if the filename starts with 'http:' or 'https:'
2) a file from the local filesystem, relative to cwd, if such a file exists.
3) A file resource from within the internal classpath and bundled content, if it exists.
If none of these exists, an error will be thrown.

View File

@ -16,7 +16,6 @@
package io.nosqlbench.engine.extensions.globalvars;
import io.nosqlbench.api.config.LabeledScenarioContext;
import io.nosqlbench.api.extensions.ScriptingExtensionPluginInfo;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nb.annotations.Service;

View File

@ -1,40 +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.engine.extensions.histologger;
import io.nosqlbench.api.engine.metrics.ActivityMetrics;
import io.nosqlbench.components.NBBaseComponent;
import com.codahale.metrics.MetricRegistry;
import io.nosqlbench.components.NBComponent;
import org.apache.logging.log4j.Logger;
import javax.script.ScriptContext;
public class HdrHistoLogPlugin {
private final Logger logger;
private final NBComponent baseComponent;
public HdrHistoLogPlugin(Logger logger, NBComponent baseComponent) {
this.logger = logger;
this.baseComponent = baseComponent;
}
public void logHistoIntervals(String session, String pattern, String filename, String interval) {
// TODO: metrics
// ActivityMetrics.addHistoLogger(session, pattern, filename, interval);
}
}

View File

@ -1,38 +0,0 @@
/*
* Copyright (c) 2022-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.engine.extensions.histologger;
import io.nosqlbench.api.config.LabeledScenarioContext;
import io.nosqlbench.api.extensions.ScriptingExtensionPluginInfo;
import io.nosqlbench.components.NBComponent;
import io.nosqlbench.nb.annotations.Service;
import org.apache.logging.log4j.Logger;
@Service(value = ScriptingExtensionPluginInfo.class, selector = "histologger")
public class HdrHistoLogPluginData implements ScriptingExtensionPluginInfo<HdrHistoLogPlugin> {
@Override
public String getDescription() {
return "allows script control of HDR histogram interval logging";
}
@Override
public HdrHistoLogPlugin getExtensionObject(final Logger logger, final NBComponent baseComponent) {
return new HdrHistoLogPlugin(logger,baseComponent);
}
}

View File

@ -1,30 +0,0 @@
histologger extension
=====================
This extension allows you to record HDR Histogram intervals
in the standard HistogramLogWriter format, for a matching set of histogram or timer metrics, at some interval you specify.
### Example
~~~
histologger.logHistoIntervals("test run 42", ".*", "hdrdata.log", "0.5s");
~~~
The arguments to logHistoStats are:
**logHistoIntervals( *comment*, *regex*, *filename*, *interval* )**, where the fields are:
- comment - a session or comment name, which is required. When this API is invoked from the command line via --log-histostats, the session name is simply the name of the scenario session.
- regex - a regular expression that is used to match metric names. The value '.*' matches everything.
- filename - the name of a file to log the statistics to.
- interval - the interval size of each row written.
All matching metrics that are capable of HDR histograms (all histograms and timers in this runtime) that also match the metric name in the pattern will be logged, at the interval provided.
The format looks like this:
~~~
#logging histograms for session testing extention histostatslogger
#[Histogram log format version 1.3]
#[StartTime: 1479149958.287 (seconds since epoch), Mon Nov 14 12:59:18 CST 2016]
"StartTimestamp","Interval_Length","Interval_Max","Interval_Compressed_Histogram"
Tag=blockingactivity1.delay,0.003,0.500,0.000,HISTFAAAABl42pNpmSzMwMDAyIAKYHwm+w9QFgA8ewJ6
Tag=csvmetrics.cycles,0.003,0.503,0.000,HISTFAAAABl42pNpmSzMwMDAyIAKYHwm+w9QFgA8ewJ6
~~~

View File

@ -15,7 +15,7 @@
*
*/
package io.nosqlbench.api.engine.conversions;
package io.nosqlbench.api.conversions;
public class ConverterUtils {
public static int[] toIntArray(String[] strings) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) 2022-2023 nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -12,9 +12,10 @@
* 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.engine.extensions.files;
package io.nosqlbench.api.files;
import io.nosqlbench.api.content.NBIO;

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 2022-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.api.histologger;
import io.nosqlbench.api.engine.metrics.HistoIntervalLogger;
import io.nosqlbench.api.engine.util.Unit;
import io.nosqlbench.components.NBBaseComponent;
import io.nosqlbench.components.NBComponent;
import java.io.File;
import java.util.regex.Pattern;
public class HdrHistoLog extends NBBaseComponent {
public HdrHistoLog(NBComponent baseComponent) {
super(baseComponent);
}
public void logHistoIntervals(String session, String pattern, String filename, String interval) {
if (filename.contains("_SESSION_")) {
filename = filename.replace("_SESSION_", session);
}
Pattern compiledPattern = Pattern.compile(pattern);
File logfile = new File(filename);
long intervalMillis = Unit.msFor(interval).orElseThrow(() ->
new RuntimeException("Unable to parse interval spec:'" + interval + '\''));
HistoIntervalLogger histoIntervalLogger =
new HistoIntervalLogger(session, logfile, compiledPattern, intervalMillis);
}
}

View File

@ -15,7 +15,7 @@
*
*/
package io.nosqlbench.api.engine.optimizers;
package io.nosqlbench.api.optimizers;
import io.nosqlbench.components.NBBaseComponent;
import io.nosqlbench.components.NBComponent;

View File

@ -15,7 +15,7 @@
*
*/
package io.nosqlbench.api.engine.optimizers;
package io.nosqlbench.api.optimizers;
import org.apache.commons.math3.analysis.MultivariateFunction;

View File

@ -15,7 +15,7 @@
*
*/
package io.nosqlbench.api.engine.optimizers;
package io.nosqlbench.api.optimizers;
import java.util.ArrayList;
import java.util.Iterator;

View File

@ -15,7 +15,7 @@
*
*/
package io.nosqlbench.api.engine.optimizers;
package io.nosqlbench.api.optimizers;
import java.util.HashMap;
import java.util.Map;

View File

@ -15,7 +15,7 @@
*
*/
package io.nosqlbench.api.engine.optimizers;
package io.nosqlbench.api.optimizers;
import org.apache.commons.math3.analysis.MultivariateFunction;
import org.graalvm.polyglot.proxy.ProxyObject;

View File

@ -28,12 +28,13 @@ import io.nosqlbench.api.engine.metrics.reporters.CsvReporter;
import io.nosqlbench.api.engine.metrics.instruments.*;
import io.nosqlbench.api.engine.metrics.reporters.MetricInstanceFilter;
import io.nosqlbench.api.engine.metrics.reporters.PromPushReporterComponent;
import io.nosqlbench.api.engine.optimizers.BobyqaOptimizerInstance;
import io.nosqlbench.api.histologger.HdrHistoLog;
import io.nosqlbench.api.optimizers.BobyqaOptimizerInstance;
import io.nosqlbench.api.files.FileAccess;
import io.nosqlbench.api.labels.NBLabels;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.DoubleSummaryStatistics;
@ -130,6 +131,14 @@ public class NBBuilders {
return new BobyqaOptimizerInstance(component);
}
public FileAccess fileAccess(String filename) {
return new FileAccess();
}
public HdrHistoLog hdrHistoLog(NBComponent component) {
return new HdrHistoLog(component);
}
public static class CsvOutputWriterBuilder {
//CsvOutputPluginWriter(NBComponent component, String filename, String... headers) {
private final NBComponent component;