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

Fixed two bugs that could cause infinite loops #304

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
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 @@ -124,6 +124,10 @@ public long onUpdate(long now) {
long remainingDuration = this.scalingPolicy.getRemainingDuration(
this.cpuFreqDemand, this.newCpuFreqSupplied, this.remainingWork);

if (remainingDuration == 0.0) {
this.remainingWork = 0.0;
}

return now + remainingDuration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public class FlowDistributor extends FlowNode implements FlowSupplier, FlowConsu
private double currentIncomingSupply; // The current supply provided by the supplier

private boolean outgoingDemandUpdateNeeded = false;
private final Set<Integer> updatedDemands =
new HashSet<>(); // Array of consumers that updated their demand in this cycle
private Set<Integer> updatedDemands = new HashSet<>(); // Array of consumers that updated their demand in this cycle

private boolean overloaded = false;

Expand Down Expand Up @@ -209,14 +208,18 @@ public void removeConsumerEdge(FlowEdge consumerEdge) {
other.setConsumerIndex(other.getConsumerIndex() - 1);
}

for (int idx_other : this.updatedDemands) {
HashSet newUpdatedDemands = new HashSet<>();

for (int idx_other : this.updatedDemands) {
if (idx_other > idx) {
this.updatedDemands.remove(idx_other);
this.updatedDemands.add(idx_other - 1);
newUpdatedDemands.add(idx_other - 1);
} else {
newUpdatedDemands.add(idx_other);
}
}

this.updatedDemands = newUpdatedDemands;

this.outgoingDemandUpdateNeeded = true;
this.invalidate();
}
Expand Down
Loading