Skip to content

Commit

Permalink
[core] Address another issue from brianfrankcooper#981 by adding "mea…
Browse files Browse the repository at this point in the history
…surement.histogram.verbose" as

a configuration option to print out the histogram buckets and default to NOT printing
out the buckets.
  • Loading branch information
manolama committed Jan 30, 2018
1 parent 381aaeb commit c6720c9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,23 @@ public class OneMeasurementHdrHistogram extends OneMeasurement {
* The default value for the hdrhistogram.percentiles property.
*/
public static final String PERCENTILES_PROPERTY_DEFAULT = "95,99";

/**
* The name of the property for determining if we should print out the buckets.
*/
public static final String VERBOSE_PROPERTY = "measurement.histogram.verbose";

/**
* Whether or not to emit the histogram buckets.
*/
private final boolean verbose;

private final List<Double> percentiles;

public OneMeasurementHdrHistogram(String name, Properties props) {
super(name);
percentiles = getPercentileValues(props.getProperty(PERCENTILES_PROPERTY, PERCENTILES_PROPERTY_DEFAULT));
verbose = Boolean.valueOf(props.getProperty(VERBOSE_PROPERTY, String.valueOf(false)));
boolean shouldLog = Boolean.parseBoolean(props.getProperty("hdrhistogram.fileoutput", "false"));
if (!shouldLog) {
log = null;
Expand Down Expand Up @@ -115,15 +126,17 @@ public void exportMeasurements(MeasurementsExporter exporter) throws IOException
exportStatusCounts(exporter);

// also export totalHistogram
for (HistogramIterationValue v : totalHistogram.recordedValues()) {
int value;
if (v.getValueIteratedTo() > (long)Integer.MAX_VALUE) {
value = Integer.MAX_VALUE;
} else {
value = (int)v.getValueIteratedTo();
if (verbose) {
for (HistogramIterationValue v : totalHistogram.recordedValues()) {
int value;
if (v.getValueIteratedTo() > (long)Integer.MAX_VALUE) {
value = Integer.MAX_VALUE;
} else {
value = (int)v.getValueIteratedTo();
}

exporter.write(getName(), Integer.toString(value), (double)v.getCountAtValueIteratedTo());
}

exporter.write(getName(), Integer.toString(value), (double)v.getCountAtValueIteratedTo());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
public class OneMeasurementHistogram extends OneMeasurement {
public static final String BUCKETS = "histogram.buckets";
public static final String BUCKETS_DEFAULT = "1000";
public static final String VERBOSE_PROPERTY = "measurement.histogram.verbose";

/**
* Specify the range of latencies to track in the histogram.
Expand Down Expand Up @@ -64,6 +65,11 @@ public class OneMeasurementHistogram extends OneMeasurement {
*/
private double totalsquaredlatency;

/**
* Whether or not to emit the histogram buckets.
*/
private final boolean verbose;

//keep a windowed version of these stats for printing status
private long windowoperations;
private long windowtotallatency;
Expand All @@ -74,6 +80,7 @@ public class OneMeasurementHistogram extends OneMeasurement {
public OneMeasurementHistogram(String name, Properties props) {
super(name);
buckets = Integer.parseInt(props.getProperty(BUCKETS, BUCKETS_DEFAULT));
verbose = Boolean.valueOf(props.getProperty(VERBOSE_PROPERTY, String.valueOf(false)));
histogram = new long[buckets];
histogramoverflow = 0;
operations = 0;
Expand Down Expand Up @@ -136,10 +143,13 @@ public void exportMeasurements(MeasurementsExporter exporter) throws IOException

exportStatusCounts(exporter);

for (int i = 0; i < buckets; i++) {
exporter.write(getName(), Integer.toString(i), histogram[i]);
if (verbose) {
for (int i = 0; i < buckets; i++) {
exporter.write(getName(), Integer.toString(i), histogram[i]);
}

exporter.write(getName(), ">" + buckets, histogramoverflow);
}
exporter.write(getName(), ">" + buckets, histogramoverflow);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import com.yahoo.ycsb.generator.ZipfianGenerator;
import com.yahoo.ycsb.measurements.Measurements;
import com.yahoo.ycsb.measurements.OneMeasurementHistogram;

import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.testng.annotations.Test;
Expand All @@ -34,6 +36,7 @@ public class TestMeasurementsExporter {
public void testJSONArrayMeasurementsExporter() throws IOException {
Properties props = new Properties();
props.put(Measurements.MEASUREMENT_TYPE_PROPERTY, "histogram");
props.put(OneMeasurementHistogram.VERBOSE_PROPERTY, "true");
Measurements mm = new Measurements(props);
ByteArrayOutputStream out = new ByteArrayOutputStream();
JSONArrayMeasurementsExporter export = new JSONArrayMeasurementsExporter(out);
Expand Down
4 changes: 4 additions & 0 deletions workloads/workload_template
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ measurementtype=histogram
# a new output file will be created.
#measurement.raw.output_file = /tmp/your_output_file_for_this_run

# Whether or not to emit individual histogram buckets when measuring
# using histograms.
# measurement.histogram.verbose = false

# JVM Reporting.
#
# Measure JVM information over time including GC counts, max and min memory
Expand Down

0 comments on commit c6720c9

Please sign in to comment.