Skip to content

Commit

Permalink
Merge pull request Netflix#804 from mattrjacobs/merge-rollback-hdr-hi…
Browse files Browse the repository at this point in the history
…stogram

Rollback the metrics refactoring
  • Loading branch information
mattrjacobs committed May 31, 2015
2 parents e68ed42 + 7facd20 commit 0a1acee
Showing 8 changed files with 449 additions and 377 deletions.
2 changes: 1 addition & 1 deletion hystrix-core/build.gradle
Original file line number Diff line number Diff line change
@@ -5,10 +5,10 @@ dependencies {
compile 'com.netflix.archaius:archaius-core:0.4.1'
compile 'io.reactivex:rxjava:1.0.10'
compile 'org.slf4j:slf4j-api:1.7.0'
compile 'org.hdrhistogram:HdrHistogram:2.1.4'
testCompile 'junit:junit-dep:4.10'
}


javadoc {
// the exclude isn't working, nor is there a subPackages options as docs suggest there should be
// we do not want the com.netflix.hystrix.util package include
Original file line number Diff line number Diff line change
@@ -18,139 +18,140 @@
import java.util.concurrent.TimeUnit;

public class RollingPercentilePerfTest {
@State(Scope.Thread)
public static class PercentileState {
HystrixRollingPercentile percentile;

@Param({"true", "false"})
public boolean percentileEnabled;

@Setup(Level.Iteration)
public void setUp() {
percentile = new HystrixRollingPercentile(
HystrixProperty.Factory.asProperty(100),
HystrixProperty.Factory.asProperty(10),
HystrixProperty.Factory.asProperty(percentileEnabled));
}
}

@State(Scope.Thread)
public static class LatencyState {
final Random r = new Random();

int latency;

@Setup(Level.Invocation)
public void setUp() {
latency = r.nextInt(100);
}
}

@Benchmark
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public HystrixRollingPercentile writeOnly(PercentileState percentileState, LatencyState latencyState) {
percentileState.percentile.addValue(latencyState.latency);
return percentileState.percentile;
}

@Benchmark
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public int readOnly(PercentileState percentileState) {
HystrixRollingPercentile percentile = percentileState.percentile;
return percentile.getMean() +
percentile.getPercentile(10) +
percentile.getPercentile(25) +
percentile.getPercentile(50) +
percentile.getPercentile(75) +
percentile.getPercentile(90) +
percentile.getPercentile(95) +
percentile.getPercentile(99) +
percentile.getPercentile(99.5);
}

@Benchmark
@Group("writeHeavy")
@GroupThreads(7)
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public HystrixRollingPercentile writeHeavyLatencyAdd(PercentileState percentileState, LatencyState latencyState) {
percentileState.percentile.addValue(latencyState.latency);
return percentileState.percentile;
}

@Benchmark
@Group("writeHeavy")
@GroupThreads(1)
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public int writeHeavyReadMetrics(PercentileState percentileState) {
HystrixRollingPercentile percentile = percentileState.percentile;
return percentile.getMean() +
percentile.getPercentile(10) +
percentile.getPercentile(25) +
percentile.getPercentile(50) +
percentile.getPercentile(75) +
percentile.getPercentile(90) +
percentile.getPercentile(95) +
percentile.getPercentile(99) +
percentile.getPercentile(99.5);
}

@Benchmark
@Group("evenSplit")
@GroupThreads(4)
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public HystrixRollingPercentile evenSplitLatencyAdd(PercentileState percentileState, LatencyState latencyState) {
percentileState.percentile.addValue(latencyState.latency);
return percentileState.percentile;
}

@Benchmark
@Group("evenSplit")
@GroupThreads(4)
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public int evenSplitReadMetrics(PercentileState percentileState) {
HystrixRollingPercentile percentile = percentileState.percentile;
return percentile.getMean() +
percentile.getPercentile(10) +
percentile.getPercentile(25) +
percentile.getPercentile(50) +
percentile.getPercentile(75) +
percentile.getPercentile(90) +
percentile.getPercentile(95) +
percentile.getPercentile(99) +
percentile.getPercentile(99.5);
}

@Benchmark
@Group("readHeavy")
@GroupThreads(1)
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public HystrixRollingPercentile readHeavyLatencyAdd(PercentileState percentileState, LatencyState latencyState) {
percentileState.percentile.addValue(latencyState.latency);
return percentileState.percentile;
}

@Benchmark
@Group("readHeavy")
@GroupThreads(7)
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public int readHeavyReadMetrics(PercentileState percentileState) {
HystrixRollingPercentile percentile = percentileState.percentile;
return percentile.getMean() +
percentile.getPercentile(10) +
percentile.getPercentile(25) +
percentile.getPercentile(50) +
percentile.getPercentile(75) +
percentile.getPercentile(90) +
percentile.getPercentile(95) +
percentile.getPercentile(99) +
percentile.getPercentile(99.5);
}
@State(Scope.Thread)
public static class PercentileState {
HystrixRollingPercentile percentile;

@Param({"true", "false"})
public boolean percentileEnabled;

@Setup(Level.Iteration)
public void setUp() {
percentile = new HystrixRollingPercentile(
HystrixProperty.Factory.asProperty(100),
HystrixProperty.Factory.asProperty(10),
HystrixProperty.Factory.asProperty(1000),
HystrixProperty.Factory.asProperty(percentileEnabled));
}
}

@State(Scope.Thread)
public static class LatencyState {
final Random r = new Random();

int latency;

@Setup(Level.Invocation)
public void setUp() {
latency = r.nextInt(100);
}
}

@Benchmark
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public HystrixRollingPercentile writeOnly(PercentileState percentileState, LatencyState latencyState) {
percentileState.percentile.addValue(latencyState.latency);
return percentileState.percentile;
}

@Benchmark
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public int readOnly(PercentileState percentileState) {
HystrixRollingPercentile percentile = percentileState.percentile;
return percentile.getMean() +
percentile.getPercentile(10) +
percentile.getPercentile(25) +
percentile.getPercentile(50) +
percentile.getPercentile(75) +
percentile.getPercentile(90) +
percentile.getPercentile(95) +
percentile.getPercentile(99) +
percentile.getPercentile(99.5);
}

@Benchmark
@Group("writeHeavy")
@GroupThreads(7)
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public HystrixRollingPercentile writeHeavyLatencyAdd(PercentileState percentileState, LatencyState latencyState) {
percentileState.percentile.addValue(latencyState.latency);
return percentileState.percentile;
}

@Benchmark
@Group("writeHeavy")
@GroupThreads(1)
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public int writeHeavyReadMetrics(PercentileState percentileState) {
HystrixRollingPercentile percentile = percentileState.percentile;
return percentile.getMean() +
percentile.getPercentile(10) +
percentile.getPercentile(25) +
percentile.getPercentile(50) +
percentile.getPercentile(75) +
percentile.getPercentile(90) +
percentile.getPercentile(95) +
percentile.getPercentile(99) +
percentile.getPercentile(99.5);
}

@Benchmark
@Group("evenSplit")
@GroupThreads(4)
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public HystrixRollingPercentile evenSplitLatencyAdd(PercentileState percentileState, LatencyState latencyState) {
percentileState.percentile.addValue(latencyState.latency);
return percentileState.percentile;
}

@Benchmark
@Group("evenSplit")
@GroupThreads(4)
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public int evenSplitReadMetrics(PercentileState percentileState) {
HystrixRollingPercentile percentile = percentileState.percentile;
return percentile.getMean() +
percentile.getPercentile(10) +
percentile.getPercentile(25) +
percentile.getPercentile(50) +
percentile.getPercentile(75) +
percentile.getPercentile(90) +
percentile.getPercentile(95) +
percentile.getPercentile(99) +
percentile.getPercentile(99.5);
}

@Benchmark
@Group("readHeavy")
@GroupThreads(1)
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public HystrixRollingPercentile readHeavyLatencyAdd(PercentileState percentileState, LatencyState latencyState) {
percentileState.percentile.addValue(latencyState.latency);
return percentileState.percentile;
}

@Benchmark
@Group("readHeavy")
@GroupThreads(7)
@BenchmarkMode({Mode.Throughput})
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public int readHeavyReadMetrics(PercentileState percentileState) {
HystrixRollingPercentile percentile = percentileState.percentile;
return percentile.getMean() +
percentile.getPercentile(10) +
percentile.getPercentile(25) +
percentile.getPercentile(50) +
percentile.getPercentile(75) +
percentile.getPercentile(90) +
percentile.getPercentile(95) +
percentile.getPercentile(99) +
percentile.getPercentile(99.5);
}
}
Original file line number Diff line number Diff line change
@@ -92,8 +92,8 @@ public static Collection<HystrixCollapserMetrics> getInstances() {
this.key = key;
this.properties = properties;

this.percentileBatchSize = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileEnabled());
this.percentileShardSize = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileEnabled());
this.percentileBatchSize = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileBucketSize(), properties.metricsRollingPercentileEnabled());
this.percentileShardSize = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileBucketSize(), properties.metricsRollingPercentileEnabled());
}

/**
Original file line number Diff line number Diff line change
@@ -142,8 +142,8 @@ public static Collection<HystrixCommandMetrics> getInstances() {
this.group = commandGroup;
this.threadPoolKey = threadPoolKey;
this.properties = properties;
this.percentileExecution = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileEnabled());
this.percentileTotal = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileEnabled());
this.percentileExecution = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileBucketSize(), properties.metricsRollingPercentileEnabled());
this.percentileTotal = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileBucketSize(), properties.metricsRollingPercentileEnabled());
this.eventNotifier = eventNotifier;
}

Loading

0 comments on commit 0a1acee

Please sign in to comment.