Skip to content

Commit 0a1acee

Browse files
committed
Merge pull request #804 from mattrjacobs/merge-rollback-hdr-histogram
Rollback the metrics refactoring
2 parents e68ed42 + 7facd20 commit 0a1acee

File tree

8 files changed

+449
-377
lines changed

8 files changed

+449
-377
lines changed

hystrix-core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ dependencies {
55
compile 'com.netflix.archaius:archaius-core:0.4.1'
66
compile 'io.reactivex:rxjava:1.0.10'
77
compile 'org.slf4j:slf4j-api:1.7.0'
8-
compile 'org.hdrhistogram:HdrHistogram:2.1.4'
98
testCompile 'junit:junit-dep:4.10'
109
}
1110

11+
1212
javadoc {
1313
// the exclude isn't working, nor is there a subPackages options as docs suggest there should be
1414
// we do not want the com.netflix.hystrix.util package include

hystrix-core/src/jmh/java/com/netflix/hystrix/perf/RollingPercentilePerfTest.java

Lines changed: 136 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -18,139 +18,140 @@
1818
import java.util.concurrent.TimeUnit;
1919

2020
public class RollingPercentilePerfTest {
21-
@State(Scope.Thread)
22-
public static class PercentileState {
23-
HystrixRollingPercentile percentile;
24-
25-
@Param({"true", "false"})
26-
public boolean percentileEnabled;
27-
28-
@Setup(Level.Iteration)
29-
public void setUp() {
30-
percentile = new HystrixRollingPercentile(
31-
HystrixProperty.Factory.asProperty(100),
32-
HystrixProperty.Factory.asProperty(10),
33-
HystrixProperty.Factory.asProperty(percentileEnabled));
34-
}
35-
}
36-
37-
@State(Scope.Thread)
38-
public static class LatencyState {
39-
final Random r = new Random();
40-
41-
int latency;
42-
43-
@Setup(Level.Invocation)
44-
public void setUp() {
45-
latency = r.nextInt(100);
46-
}
47-
}
48-
49-
@Benchmark
50-
@BenchmarkMode({Mode.Throughput})
51-
@OutputTimeUnit(TimeUnit.MILLISECONDS)
52-
public HystrixRollingPercentile writeOnly(PercentileState percentileState, LatencyState latencyState) {
53-
percentileState.percentile.addValue(latencyState.latency);
54-
return percentileState.percentile;
55-
}
56-
57-
@Benchmark
58-
@BenchmarkMode({Mode.Throughput})
59-
@OutputTimeUnit(TimeUnit.MILLISECONDS)
60-
public int readOnly(PercentileState percentileState) {
61-
HystrixRollingPercentile percentile = percentileState.percentile;
62-
return percentile.getMean() +
63-
percentile.getPercentile(10) +
64-
percentile.getPercentile(25) +
65-
percentile.getPercentile(50) +
66-
percentile.getPercentile(75) +
67-
percentile.getPercentile(90) +
68-
percentile.getPercentile(95) +
69-
percentile.getPercentile(99) +
70-
percentile.getPercentile(99.5);
71-
}
72-
73-
@Benchmark
74-
@Group("writeHeavy")
75-
@GroupThreads(7)
76-
@BenchmarkMode({Mode.Throughput})
77-
@OutputTimeUnit(TimeUnit.MILLISECONDS)
78-
public HystrixRollingPercentile writeHeavyLatencyAdd(PercentileState percentileState, LatencyState latencyState) {
79-
percentileState.percentile.addValue(latencyState.latency);
80-
return percentileState.percentile;
81-
}
82-
83-
@Benchmark
84-
@Group("writeHeavy")
85-
@GroupThreads(1)
86-
@BenchmarkMode({Mode.Throughput})
87-
@OutputTimeUnit(TimeUnit.MILLISECONDS)
88-
public int writeHeavyReadMetrics(PercentileState percentileState) {
89-
HystrixRollingPercentile percentile = percentileState.percentile;
90-
return percentile.getMean() +
91-
percentile.getPercentile(10) +
92-
percentile.getPercentile(25) +
93-
percentile.getPercentile(50) +
94-
percentile.getPercentile(75) +
95-
percentile.getPercentile(90) +
96-
percentile.getPercentile(95) +
97-
percentile.getPercentile(99) +
98-
percentile.getPercentile(99.5);
99-
}
100-
101-
@Benchmark
102-
@Group("evenSplit")
103-
@GroupThreads(4)
104-
@BenchmarkMode({Mode.Throughput})
105-
@OutputTimeUnit(TimeUnit.MILLISECONDS)
106-
public HystrixRollingPercentile evenSplitLatencyAdd(PercentileState percentileState, LatencyState latencyState) {
107-
percentileState.percentile.addValue(latencyState.latency);
108-
return percentileState.percentile;
109-
}
110-
111-
@Benchmark
112-
@Group("evenSplit")
113-
@GroupThreads(4)
114-
@BenchmarkMode({Mode.Throughput})
115-
@OutputTimeUnit(TimeUnit.MILLISECONDS)
116-
public int evenSplitReadMetrics(PercentileState percentileState) {
117-
HystrixRollingPercentile percentile = percentileState.percentile;
118-
return percentile.getMean() +
119-
percentile.getPercentile(10) +
120-
percentile.getPercentile(25) +
121-
percentile.getPercentile(50) +
122-
percentile.getPercentile(75) +
123-
percentile.getPercentile(90) +
124-
percentile.getPercentile(95) +
125-
percentile.getPercentile(99) +
126-
percentile.getPercentile(99.5);
127-
}
128-
129-
@Benchmark
130-
@Group("readHeavy")
131-
@GroupThreads(1)
132-
@BenchmarkMode({Mode.Throughput})
133-
@OutputTimeUnit(TimeUnit.MILLISECONDS)
134-
public HystrixRollingPercentile readHeavyLatencyAdd(PercentileState percentileState, LatencyState latencyState) {
135-
percentileState.percentile.addValue(latencyState.latency);
136-
return percentileState.percentile;
137-
}
138-
139-
@Benchmark
140-
@Group("readHeavy")
141-
@GroupThreads(7)
142-
@BenchmarkMode({Mode.Throughput})
143-
@OutputTimeUnit(TimeUnit.MILLISECONDS)
144-
public int readHeavyReadMetrics(PercentileState percentileState) {
145-
HystrixRollingPercentile percentile = percentileState.percentile;
146-
return percentile.getMean() +
147-
percentile.getPercentile(10) +
148-
percentile.getPercentile(25) +
149-
percentile.getPercentile(50) +
150-
percentile.getPercentile(75) +
151-
percentile.getPercentile(90) +
152-
percentile.getPercentile(95) +
153-
percentile.getPercentile(99) +
154-
percentile.getPercentile(99.5);
155-
}
21+
@State(Scope.Thread)
22+
public static class PercentileState {
23+
HystrixRollingPercentile percentile;
24+
25+
@Param({"true", "false"})
26+
public boolean percentileEnabled;
27+
28+
@Setup(Level.Iteration)
29+
public void setUp() {
30+
percentile = new HystrixRollingPercentile(
31+
HystrixProperty.Factory.asProperty(100),
32+
HystrixProperty.Factory.asProperty(10),
33+
HystrixProperty.Factory.asProperty(1000),
34+
HystrixProperty.Factory.asProperty(percentileEnabled));
35+
}
36+
}
37+
38+
@State(Scope.Thread)
39+
public static class LatencyState {
40+
final Random r = new Random();
41+
42+
int latency;
43+
44+
@Setup(Level.Invocation)
45+
public void setUp() {
46+
latency = r.nextInt(100);
47+
}
48+
}
49+
50+
@Benchmark
51+
@BenchmarkMode({Mode.Throughput})
52+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
53+
public HystrixRollingPercentile writeOnly(PercentileState percentileState, LatencyState latencyState) {
54+
percentileState.percentile.addValue(latencyState.latency);
55+
return percentileState.percentile;
56+
}
57+
58+
@Benchmark
59+
@BenchmarkMode({Mode.Throughput})
60+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
61+
public int readOnly(PercentileState percentileState) {
62+
HystrixRollingPercentile percentile = percentileState.percentile;
63+
return percentile.getMean() +
64+
percentile.getPercentile(10) +
65+
percentile.getPercentile(25) +
66+
percentile.getPercentile(50) +
67+
percentile.getPercentile(75) +
68+
percentile.getPercentile(90) +
69+
percentile.getPercentile(95) +
70+
percentile.getPercentile(99) +
71+
percentile.getPercentile(99.5);
72+
}
73+
74+
@Benchmark
75+
@Group("writeHeavy")
76+
@GroupThreads(7)
77+
@BenchmarkMode({Mode.Throughput})
78+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
79+
public HystrixRollingPercentile writeHeavyLatencyAdd(PercentileState percentileState, LatencyState latencyState) {
80+
percentileState.percentile.addValue(latencyState.latency);
81+
return percentileState.percentile;
82+
}
83+
84+
@Benchmark
85+
@Group("writeHeavy")
86+
@GroupThreads(1)
87+
@BenchmarkMode({Mode.Throughput})
88+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
89+
public int writeHeavyReadMetrics(PercentileState percentileState) {
90+
HystrixRollingPercentile percentile = percentileState.percentile;
91+
return percentile.getMean() +
92+
percentile.getPercentile(10) +
93+
percentile.getPercentile(25) +
94+
percentile.getPercentile(50) +
95+
percentile.getPercentile(75) +
96+
percentile.getPercentile(90) +
97+
percentile.getPercentile(95) +
98+
percentile.getPercentile(99) +
99+
percentile.getPercentile(99.5);
100+
}
101+
102+
@Benchmark
103+
@Group("evenSplit")
104+
@GroupThreads(4)
105+
@BenchmarkMode({Mode.Throughput})
106+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
107+
public HystrixRollingPercentile evenSplitLatencyAdd(PercentileState percentileState, LatencyState latencyState) {
108+
percentileState.percentile.addValue(latencyState.latency);
109+
return percentileState.percentile;
110+
}
111+
112+
@Benchmark
113+
@Group("evenSplit")
114+
@GroupThreads(4)
115+
@BenchmarkMode({Mode.Throughput})
116+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
117+
public int evenSplitReadMetrics(PercentileState percentileState) {
118+
HystrixRollingPercentile percentile = percentileState.percentile;
119+
return percentile.getMean() +
120+
percentile.getPercentile(10) +
121+
percentile.getPercentile(25) +
122+
percentile.getPercentile(50) +
123+
percentile.getPercentile(75) +
124+
percentile.getPercentile(90) +
125+
percentile.getPercentile(95) +
126+
percentile.getPercentile(99) +
127+
percentile.getPercentile(99.5);
128+
}
129+
130+
@Benchmark
131+
@Group("readHeavy")
132+
@GroupThreads(1)
133+
@BenchmarkMode({Mode.Throughput})
134+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
135+
public HystrixRollingPercentile readHeavyLatencyAdd(PercentileState percentileState, LatencyState latencyState) {
136+
percentileState.percentile.addValue(latencyState.latency);
137+
return percentileState.percentile;
138+
}
139+
140+
@Benchmark
141+
@Group("readHeavy")
142+
@GroupThreads(7)
143+
@BenchmarkMode({Mode.Throughput})
144+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
145+
public int readHeavyReadMetrics(PercentileState percentileState) {
146+
HystrixRollingPercentile percentile = percentileState.percentile;
147+
return percentile.getMean() +
148+
percentile.getPercentile(10) +
149+
percentile.getPercentile(25) +
150+
percentile.getPercentile(50) +
151+
percentile.getPercentile(75) +
152+
percentile.getPercentile(90) +
153+
percentile.getPercentile(95) +
154+
percentile.getPercentile(99) +
155+
percentile.getPercentile(99.5);
156+
}
156157
}

hystrix-core/src/main/java/com/netflix/hystrix/HystrixCollapserMetrics.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public static Collection<HystrixCollapserMetrics> getInstances() {
9292
this.key = key;
9393
this.properties = properties;
9494

95-
this.percentileBatchSize = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileEnabled());
96-
this.percentileShardSize = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileEnabled());
95+
this.percentileBatchSize = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileBucketSize(), properties.metricsRollingPercentileEnabled());
96+
this.percentileShardSize = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileBucketSize(), properties.metricsRollingPercentileEnabled());
9797
}
9898

9999
/**

hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandMetrics.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ public static Collection<HystrixCommandMetrics> getInstances() {
142142
this.group = commandGroup;
143143
this.threadPoolKey = threadPoolKey;
144144
this.properties = properties;
145-
this.percentileExecution = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileEnabled());
146-
this.percentileTotal = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileEnabled());
145+
this.percentileExecution = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileBucketSize(), properties.metricsRollingPercentileEnabled());
146+
this.percentileTotal = new HystrixRollingPercentile(properties.metricsRollingPercentileWindowInMilliseconds(), properties.metricsRollingPercentileWindowBuckets(), properties.metricsRollingPercentileBucketSize(), properties.metricsRollingPercentileEnabled());
147147
this.eventNotifier = eventNotifier;
148148
}
149149

0 commit comments

Comments
 (0)