mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
allow activities to set hdr-digits
This commit is contained in:
parent
fa846a3c94
commit
d43941d10d
@ -244,7 +244,7 @@ public class SimpleActivity implements Activity {
|
|||||||
* by the provided ratios. Also, modify the ActivityDef with reasonable defaults when requested.
|
* by the provided ratios. Also, modify the ActivityDef with reasonable defaults when requested.
|
||||||
* @param seq - The {@link OpSequence} to derive the defaults from
|
* @param seq - The {@link OpSequence} to derive the defaults from
|
||||||
*/
|
*/
|
||||||
public void setDefaultsFromOpSequence(OpSequence seq) {
|
public void setDefaultsFromOpSequence(OpSequence<?> seq) {
|
||||||
Optional<String> strideOpt = getParams().getOptionalString("stride");
|
Optional<String> strideOpt = getParams().getOptionalString("stride");
|
||||||
if (strideOpt.isEmpty()) {
|
if (strideOpt.isEmpty()) {
|
||||||
String stride = String.valueOf(seq.getSequence().length);
|
String stride = String.valueOf(seq.getSequence().length);
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package io.nosqlbench.engine.api.metrics;
|
package io.nosqlbench.engine.api.metrics;
|
||||||
|
|
||||||
import com.codahale.metrics.*;
|
import com.codahale.metrics.*;
|
||||||
import io.nosqlbench.engine.api.activityapi.core.Activity;
|
|
||||||
import io.nosqlbench.engine.api.activityapi.core.MetricRegistryService;
|
import io.nosqlbench.engine.api.activityapi.core.MetricRegistryService;
|
||||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||||
import io.nosqlbench.engine.api.util.Unit;
|
import io.nosqlbench.engine.api.util.Unit;
|
||||||
@ -37,6 +36,11 @@ import java.util.regex.Pattern;
|
|||||||
public class ActivityMetrics {
|
public class ActivityMetrics {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(ActivityMetrics.class);
|
private final static Logger logger = LoggerFactory.getLogger(ActivityMetrics.class);
|
||||||
|
|
||||||
|
public static final String HDRDIGITS_PARAM = "hdr-digits";
|
||||||
|
public static final int DEFAULT_HDRDIGITS= 4;
|
||||||
|
private static int _HDRDIGITS = DEFAULT_HDRDIGITS;
|
||||||
|
|
||||||
private static MetricRegistry registry;
|
private static MetricRegistry registry;
|
||||||
|
|
||||||
public static MetricFilter METRIC_FILTER = (name, metric) -> {
|
public static MetricFilter METRIC_FILTER = (name, metric) -> {
|
||||||
@ -44,14 +48,13 @@ public class ActivityMetrics {
|
|||||||
};
|
};
|
||||||
private static List<MetricsCloseable> metricsCloseables = new ArrayList<>();
|
private static List<MetricsCloseable> metricsCloseables = new ArrayList<>();
|
||||||
|
|
||||||
private static int significantDigits = 4;
|
|
||||||
|
|
||||||
public static int getSignificantDigits() {
|
public static int getHdrDigits() {
|
||||||
return significantDigits;
|
return _HDRDIGITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setHdrDigits(int hdrDigits) {
|
public static void setHdrDigits(int hdrDigits) {
|
||||||
ActivityMetrics.significantDigits = hdrDigits;
|
ActivityMetrics._HDRDIGITS = hdrDigits;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActivityMetrics() {
|
private ActivityMetrics() {
|
||||||
@ -99,6 +102,10 @@ public class ActivityMetrics {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* <p>Create a timer associated with an activity.</p>
|
* <p>Create a timer associated with an activity.</p>
|
||||||
|
*
|
||||||
|
* <p>If the provide ActivityDef contains a parameter "hdr-digits", then it will be used to set the number of
|
||||||
|
* significant digits on the histogram's precision.</p>
|
||||||
|
*
|
||||||
* <p>This method ensures that if multiple threads attempt to create the same-named metric on a given activity,
|
* <p>This method ensures that if multiple threads attempt to create the same-named metric on a given activity,
|
||||||
* that only one of them succeeds.</p>
|
* that only one of them succeeds.</p>
|
||||||
*
|
*
|
||||||
@ -109,15 +116,25 @@ public class ActivityMetrics {
|
|||||||
public static Timer timer(ActivityDef activityDef, String name) {
|
public static Timer timer(ActivityDef activityDef, String name) {
|
||||||
String fullMetricName = activityDef.getAlias() + "." + name;
|
String fullMetricName = activityDef.getAlias() + "." + name;
|
||||||
Timer registeredTimer = (Timer) register(activityDef, name, () ->
|
Timer registeredTimer = (Timer) register(activityDef, name, () ->
|
||||||
new NicerTimer(fullMetricName, new DeltaHdrHistogramReservoir(fullMetricName, significantDigits)));
|
new NicerTimer(fullMetricName,
|
||||||
|
new DeltaHdrHistogramReservoir(
|
||||||
|
fullMetricName,
|
||||||
|
activityDef.getParams().getOptionalInteger(HDRDIGITS_PARAM).orElse(_HDRDIGITS)
|
||||||
|
)
|
||||||
|
));
|
||||||
return registeredTimer;
|
return registeredTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Create a histogram associated with an activity.</p>
|
* <p>Create an HDR histogram associated with an activity.</p>
|
||||||
|
*
|
||||||
|
* <p>If the provide ActivityDef contains a parameter "hdr-digits", then it will be used to set the number of
|
||||||
|
* significant digits on the histogram's precision.</p>
|
||||||
|
*
|
||||||
* <p>This method ensures that if multiple threads attempt to create the same-named metric on a given activity,
|
* <p>This method ensures that if multiple threads attempt to create the same-named metric on a given activity,
|
||||||
* that only one of them succeeds.</p>
|
* that only one of them succeeds.</p>
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @param activityDef an associated activity def
|
* @param activityDef an associated activity def
|
||||||
* @param name a simple, descriptive name for the histogram
|
* @param name a simple, descriptive name for the histogram
|
||||||
* @return the histogram, perhaps a different one if it has already been registered
|
* @return the histogram, perhaps a different one if it has already been registered
|
||||||
@ -125,7 +142,13 @@ public class ActivityMetrics {
|
|||||||
public static Histogram histogram(ActivityDef activityDef, String name) {
|
public static Histogram histogram(ActivityDef activityDef, String name) {
|
||||||
String fullMetricName = activityDef.getAlias() + "." + name;
|
String fullMetricName = activityDef.getAlias() + "." + name;
|
||||||
return (Histogram) register(activityDef, name, () ->
|
return (Histogram) register(activityDef, name, () ->
|
||||||
new NicerHistogram(fullMetricName, new DeltaHdrHistogramReservoir(fullMetricName, significantDigits)));
|
new NicerHistogram(
|
||||||
|
fullMetricName,
|
||||||
|
new DeltaHdrHistogramReservoir(
|
||||||
|
fullMetricName,
|
||||||
|
activityDef.getParams().getOptionalInteger(HDRDIGITS_PARAM).orElse(_HDRDIGITS)
|
||||||
|
)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -360,9 +360,21 @@ In detail, the rendering appears as `0.0(A), 0.0(B), 0.0(C), 0.25(A),
|
|||||||
0.5(A), 0.5(B), 0.75(A)`, which yields `A B C A A B A` as the op
|
0.5(A), 0.5(B), 0.75(A)`, which yields `A B C A A B A` as the op
|
||||||
sequence.
|
sequence.
|
||||||
|
|
||||||
This sequencer is most useful when you want a stable ordering of
|
This sequencer is most useful when you want a stable ordering of operation from a rich mix of statement types, where
|
||||||
operation from a rich mix of statement types, where each operations is
|
each operations is spaced as evenly as possible over time, and where it is not important to control the cycle-by-cycle
|
||||||
spaced as evenly as possible over time, and where it is not important to
|
sequencing of statements.
|
||||||
control the cycle-by-cycle sequencing of statements.
|
|
||||||
|
|
||||||
|
## hdr-digits
|
||||||
|
|
||||||
|
- `hdr-digits=3`
|
||||||
|
- _default_: `4`
|
||||||
|
- _required_: no
|
||||||
|
- _dynamic_: no
|
||||||
|
|
||||||
|
This parameter determines the number of significant digits used in all HDR histograms for metrics collected from this
|
||||||
|
activity. The default of 4 allows 4 significant digits, which means *up to* 10000 distinct histogram buckets per named
|
||||||
|
metric, per histogram interval. This does not mean that there _will be_ 10000 distinct buckets, but it means there could
|
||||||
|
be if there is significant volume and variety in the measurements.
|
||||||
|
|
||||||
|
If you are running a scenario that creates many activities, then you can set `hdr-digits=1` on some of them to save
|
||||||
|
client resources.
|
||||||
|
@ -160,7 +160,7 @@ you can do so this way:
|
|||||||
|
|
||||||
The default is 4 digits, which creates 10000 equisized histogram buckets for every named metric in every reporting
|
The default is 4 digits, which creates 10000 equisized histogram buckets for every named metric in every reporting
|
||||||
interval. For longer running test or for test which do not require this level of precision in metrics, you can set this
|
interval. For longer running test or for test which do not require this level of precision in metrics, you can set this
|
||||||
down to 3 or 2.
|
down to 3 or 2. Note that this only sets the global default. Each activity can also override this value.
|
||||||
|
|
||||||
|
|
||||||
Enlist engineblock to stand up your metrics infrastructure using a local docker runtime:
|
Enlist engineblock to stand up your metrics infrastructure using a local docker runtime:
|
||||||
|
Loading…
Reference in New Issue
Block a user