Martin Sivák has posted comments on this change. Change subject: sla: Update balancers and add memory based load balancing ......................................................................
Patch Set 4: (10 comments) https://gerrit.ovirt.org/#/c/38189/4/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuAndMemoryBalancingPolicyUnit.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuAndMemoryBalancingPolicyUnit.java: Line 63: * returns list of Hosts with Line 64: * cpuUtilization >= highUtilization Line 65: * && cpuOverCommitMinutes >= CpuOverCommitDurationMinutes Line 66: */ Line 67: List<VDS> overUtilizedCPUHosts = getPrimarySources(cluster, hosts, parameters); > few notes regarding the getXXX sources api: I copied most of the code intact so I would rather return empty structures (and kiil the if null blocks) in a separate patch. Well actually the naming of overUtilizedCPUHosts (and memory) is wrong here. The abstract class should not care what source is primary.. Line 68: Line 69: /* get hosts with not enough free memory */ Line 70: final List<VDS> overUtilizedMemoryHosts = getSecondarySources(cluster, hosts, parameters); Line 71: Line 109: // if no host has memory to spare, then there is nothing we can do to balance it.. Line 110: if (underUtilizedHosts == null || underUtilizedHosts.size() == 0) { Line 111: log.warn("All hosts are Memory over-utilized, can't Memory balance the cluster '{}'", cluster.getName()); Line 112: return null; Line 113: } > something to consider: returning an empty Pair if it makes sense The SchedulingManager's logic expects either null or proper response here. Line 114: Line 115: FindVmAndDestinations.Result result = findVmAndDestinations.invoke(overUtilizedMemoryHosts, underUtilizedHosts, getVmDao()); Line 116: if (result != null) { Line 117: destinationHosts = result.getDestinationHosts(); Line 123: || vmToMigrate == null) { Line 124: return null; Line 125: } Line 126: Line 127: List<Guid> destinationHostsKeys = new ArrayList<Guid>(); > you can spare that block and use Entities.getIds(destinationHosts) Done Line 128: for (VDS vds : destinationHosts) { Line 129: destinationHostsKeys.add(vds.getId()); Line 130: } Line 131: Line 149: List<VDS> result = new ArrayList<>(); Line 150: Line 151: for (VDS h: hosts) { Line 152: if (h.getMaxSchedulingMemory() > lowFreeMemoryLimit Line 153: && h.getVmCount() >= minVmCount) { > why a host which has less vms than the minumum is not under-utilized? It is needed for evenly balanced vs. power saving balancing. Power saving uses under utilized hosts as source as well (to clean a full host and shut it down) and so passes 1 here. Evenly balanced uses 0. Line 154: result.add(h); Line 155: } Line 156: } Line 157: Line 171: List<VDS> result = new ArrayList<>(); Line 172: Line 173: for (VDS h: hosts) { Line 174: if (h.getMaxSchedulingMemory() < highFreeMemoryLimit Line 175: && h.getVmCount() > 1) { > I wonder if we have 1 VM and we're > highFreeMemoryLimit, shouldn't we stri Well the logic here is that we won't improve stuff much by migrating if there is only one VM. The VM itself is fine. Line 176: result.add(h); Line 177: } Line 178: } Line 179: Line 201: public boolean eval(VDS p) { Line 202: return (p.getUsageCpuPercent() + calcSpmCpuConsumption(p)) >= highUtilization Line 203: && p.getCpuOverCommitTimestamp() != null Line 204: && (new Date().getTime() - p.getCpuOverCommitTimestamp().getTime()) Line 205: >= cpuOverCommitDurationMinutes * 1000L * 60L > please use TimeUnit.MINUTES.toMilis Done Line 206: && p.getVmCount() > 0; Line 207: } Line 208: }); Line 209: Collections.sort(overUtilizedHosts, new ReverseComparator(VdsCpuUsageComparator.INSTANCE)); Line 221: return (p.getUsageCpuPercent() + calcSpmCpuConsumption(p)) < lowUtilization Line 222: && p.getVmCount() >= minVmCount Line 223: && (p.getCpuOverCommitTimestamp() == null Line 224: || (new Date().getTime() - p.getCpuOverCommitTimestamp().getTime()) < Line 225: cpuOverCommitDurationMinutes * 60L * 1000L); > same Done Line 226: } Line 227: }); Line 228: Collections.sort(underUtilizedHosts, VdsCpuUsageComparator.INSTANCE); Line 229: return underUtilizedHosts; https://gerrit.ovirt.org/#/c/38189/4/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/utils/VdsCpuUsageComparator.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/utils/VdsCpuUsageComparator.java: Line 13: INSTANCE; Line 14: Line 15: @Override Line 16: public int compare(VDS o1, VDS o2) { Line 17: return Integer.valueOf(calculateCpuUsage(o1)).compareTo(calculateCpuUsage(o2)); > Integer.compare is a static method This needs to stay as it is because of the Pending resource manager. Which is just a draft, but... Line 18: } Line 19: Line 20: private static int calculateCpuUsage(VDS o1) { Line 21: return o1.getUsageCpuPercent() * SlaValidator.getEffectiveCpuCores(o1) / o1.getVdsStrength(); https://gerrit.ovirt.org/#/c/38189/4/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/utils/VmCpuUsageComparator.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/utils/VmCpuUsageComparator.java: Line 10: public enum VmCpuUsageComparator implements Comparator<VM> { Line 11: INSTANCE; Line 12: Line 13: @Override Line 14: public int compare(VM o1, VM o2) { > pls change o1 to vm1 and so on. Done Line 15: return Integer.valueOf(calculateCpuUsage(o1)).compareTo(calculateCpuUsage(o2)); Line 16: } Line 17: Line 18: private static int calculateCpuUsage(VM o1) { Line 11: INSTANCE; Line 12: Line 13: @Override Line 14: public int compare(VM o1, VM o2) { Line 15: return Integer.valueOf(calculateCpuUsage(o1)).compareTo(calculateCpuUsage(o2)); > just use the static version of it - Integer.compare(x,y) Done Line 16: } Line 17: Line 18: private static int calculateCpuUsage(VM o1) { Line 19: return o1.getUsageCpuPercent() * o1.getNumOfCpus(); -- To view, visit https://gerrit.ovirt.org/38189 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I1fe13267feca89ab6c8fb9d85656f05930d0b333 Gerrit-PatchSet: 4 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Sivák <msi...@redhat.com> Gerrit-Reviewer: Martin Sivák <msi...@redhat.com> Gerrit-Reviewer: Roy Golan <rgo...@redhat.com> Gerrit-Reviewer: Tomer Saban <tsa...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches