Skip to content

Commit

Permalink
drop excessive samples, return zero tracked rtt if no samples in window
Browse files Browse the repository at this point in the history
remove heuristic multiplier for window size
  • Loading branch information
IgorPerikov committed Jun 5, 2019
1 parent e6f6caa commit 29f7836
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ImmutablePercentileSampleWindow implements SampleWindow {
this.percentile = percentile;
}

ImmutablePercentileSampleWindow(
private ImmutablePercentileSampleWindow(
long minRtt,
int maxInFlight,
boolean didDrop,
Expand All @@ -54,6 +54,9 @@ class ImmutablePercentileSampleWindow implements SampleWindow {

@Override
public ImmutablePercentileSampleWindow addSample(long rtt, int inflight, boolean didDrop) {
if (sampleCount >= observedRtts.length()) {
return this;
}
observedRtts.set(sampleCount, rtt);
return new ImmutablePercentileSampleWindow(
Math.min(minRtt, rtt),
Expand All @@ -72,6 +75,9 @@ public long getCandidateRttNanos() {

@Override
public long getTrackedRttNanos() {
if (sampleCount == 0) {
return 0;
}
long[] copyOfObservedRtts = new long[sampleCount];
for (int i = 0; i < sampleCount; i++) {
copyOfObservedRtts[i] = observedRtts.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public static PercentileSampleWindowFactory of(double percentile, int windowSize

@Override
public ImmutablePercentileSampleWindow newInstance() {
return new ImmutablePercentileSampleWindow(percentile, (int) (windowSize * 1.2));
return new ImmutablePercentileSampleWindow(percentile, windowSize);
}
}

0 comments on commit 29f7836

Please sign in to comment.