summaryrefslogtreecommitdiff
path: root/opendc-compute
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2025-09-26 16:17:39 +0200
committerGitHub <noreply@github.com>2025-09-26 16:17:39 +0200
commit2ba57fd06560f096def01a31f8e47827f0f01da0 (patch)
tree27ac3c625b1e406a6f574b30c6c0eab0e6eb862d /opendc-compute
parente88adbc3fc15a2de717f9478454c5a5229ece10e (diff)
Converted maps in the FlowDistributor to Arrays for performance (#373)
* Updated the flowDistributor to use arrays instead of maps to improve performance. * Small cleanup
Diffstat (limited to 'opendc-compute')
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt10
1 files changed, 6 insertions, 4 deletions
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt
index 8eaf95d1..b5a8dbba 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt
+++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt
@@ -68,10 +68,11 @@ public class HostsProvisioningStep internal constructor(
simPowerSources.add(simPowerSource)
service.addPowerSource(simPowerSource)
- val hostDistributor =
+ val powerDistributor =
FlowDistributorFactory.getFlowDistributor(
engine,
DistributionPolicy.MAX_MIN_FAIRNESS,
+ cluster.hostSpecs.size,
)
val carbonFragments = getCarbonFragments(cluster.powerSource.carbonTracePath)
@@ -90,6 +91,7 @@ public class HostsProvisioningStep internal constructor(
FlowDistributorFactory.getFlowDistributor(
engine,
DistributionPolicy.MAX_MIN_FAIRNESS,
+ 2,
)
FlowEdge(batteryDistributor, simPowerSource)
@@ -120,11 +122,11 @@ public class HostsProvisioningStep internal constructor(
carbonModel?.addReceiver(batteryPolicy)
- FlowEdge(hostDistributor, batteryAggregator, ResourceType.POWER)
+ FlowEdge(powerDistributor, batteryAggregator, ResourceType.POWER)
service.addBattery(battery)
} else {
- FlowEdge(hostDistributor, simPowerSource, ResourceType.POWER)
+ FlowEdge(powerDistributor, simPowerSource, ResourceType.POWER)
}
// Create hosts, they are connected to the powerMux when SimMachine is created
@@ -141,7 +143,7 @@ public class HostsProvisioningStep internal constructor(
hostSpec.gpuPowerModel,
hostSpec.embodiedCarbon,
hostSpec.expectedLifetime,
- hostDistributor,
+ powerDistributor,
)
require(simHosts.add(simHost)) { "Host with name ${hostSpec.name} already exists" }