Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#147: let AIMD grow by configurable amount #153

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static class Builder {
private int minLimit = 20;
private int initialLimit = 20;
private int maxLimit = 200;
private int increase = 1;
private double backoffRatio = 0.9;
private long timeout = DEFAULT_TIMEOUT;

Expand All @@ -55,6 +56,12 @@ public Builder backoffRatio(double backoffRatio) {
return this;
}

public Builder increaseBy(int increase) {
Preconditions.checkArgument(increase >= 1, "Increase value must be >= 1");
this.increase = increase;
return this;
}

/**
* Timeout threshold that when exceeded equates to a drop.
* @param timeout
Expand All @@ -75,14 +82,16 @@ public AIMDLimit build() {
public static Builder newBuilder() {
return new Builder();
}


private final int increase;
private final double backoffRatio;
private final long timeout;
private final int minLimit;
private final int maxLimit;

private AIMDLimit(Builder builder) {
super(builder.initialLimit);
this.increase = builder.increase;
this.backoffRatio = builder.backoffRatio;
this.timeout = builder.timeout;
this.maxLimit = builder.maxLimit;
Expand All @@ -96,7 +105,7 @@ protected int _update(long startTime, long rtt, int inflight, boolean didDrop) {
if (didDrop || rtt > timeout) {
currentLimit = (int) (currentLimit * backoffRatio);
} else if (inflight * 2 >= currentLimit) {
currentLimit = currentLimit + 1;
currentLimit = currentLimit + increase;
}

if (currentLimit >= maxLimit) {
Expand Down