xintongsong commented on a change in pull request #8704: [FLINK-12812][runtime]
Set resource profiles for task slots
URL: https://github.com/apache/flink/pull/8704#discussion_r300238018
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/types/ResourceProfile.java
##########
@@ -284,12 +301,39 @@ else if (obj != null && obj.getClass() ==
ResourceProfile.class) {
return this.cpuCores == that.cpuCores &&
this.heapMemoryInMB ==
that.heapMemoryInMB &&
this.directMemoryInMB ==
that.directMemoryInMB &&
+ this.nativeMemoryInMB ==
that.nativeMemoryInMB &&
this.networkMemoryInMB ==
that.networkMemoryInMB &&
+ this.managedMemoryInMB ==
that.managedMemoryInMB &&
Objects.equals(extendedResources,
that.extendedResources);
}
return false;
}
+ public boolean approximate(ResourceProfile that) {
+ if (that == null) {
+ return false;
+ }
+ if (Math.abs(this.cpuCores - that.cpuCores) > 1e-6f) {
Review comment:
Yes, this is about the rounding errors during the profile calculation.
The calculation of profiles involves multiplying integer values with
floating values. Rounding the floating value product to integer value will
cause error. E.g., rounded result of `Total * Fraction` and `Total - Total * (1
- Fraction)` may be different, where `Total` is an integer value and `Fraction`
is a floating value.
Each time we do such rounding, we may get an error with max value 1. Since
there are two of such fraction based calculation (for managed memory and
network memory), I set the max error allowed here to 2.
This approximate matching is only used for matching `PendingTaskManagerSlot`
with slot registered from TM. It can be replaced with exact matching once we
unify the TM resource configuration. After we unify the TM resource
configurations, there will be no more resource calculations on TM side. For
Yarn, RM will calculate the resource profile and pass the calculation result to
the TM to be started, so the pending slots and the actual slots should have
exact same profiles. For standalone, there shouldn't be any pending slots.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services