You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celeborn.apache.org by zh...@apache.org on 2023/03/03 09:57:22 UTC

[incubator-celeborn] branch branch-0.2 updated: [CELEBORN-348][FOLLOWUP] Refine comparator to support nanoseconds whi… (#1305)

This is an automated email from the ASF dual-hosted git repository.

zhouky pushed a commit to branch branch-0.2
in repository https://gitbox.apache.org/repos/asf/incubator-celeborn.git


The following commit(s) were added to refs/heads/branch-0.2 by this push:
     new ff18bce61 [CELEBORN-348][FOLLOWUP] Refine comparator to support nanoseconds whi… (#1305)
ff18bce61 is described below

commit ff18bce61b8451a9db492fa00bb7ab96fe7b32a3
Author: Keyong Zhou <zh...@apache.org>
AuthorDate: Fri Mar 3 17:55:59 2023 +0800

    [CELEBORN-348][FOLLOWUP] Refine comparator to support nanoseconds whi… (#1305)
---
 .../celeborn/service/deploy/master/SlotsAllocator.java       | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/master/src/main/java/org/apache/celeborn/service/deploy/master/SlotsAllocator.java b/master/src/main/java/org/apache/celeborn/service/deploy/master/SlotsAllocator.java
index a22ef7656..44901668b 100644
--- a/master/src/main/java/org/apache/celeborn/service/deploy/master/SlotsAllocator.java
+++ b/master/src/main/java/org/apache/celeborn/service/deploy/master/SlotsAllocator.java
@@ -262,12 +262,12 @@ public class SlotsAllocator {
       double fetchTimeWeight) {
     List<List<DiskInfo>> diskGroups = new ArrayList<>();
     usableDisks.sort(
-        (o1, o2) ->
-            Math.toIntExact(
-                (long)
-                    ((o1.avgFlushTime() * flushTimeWeight + o1.avgFetchTime() * fetchTimeWeight)
-                        - (o2.avgFlushTime() * flushTimeWeight
-                            + o2.avgFetchTime() * fetchTimeWeight))));
+        (o1, o2) -> {
+          double delta =
+              (o1.avgFlushTime() * flushTimeWeight + o1.avgFetchTime() * fetchTimeWeight)
+                  - (o2.avgFlushTime() * flushTimeWeight + o2.avgFetchTime() * fetchTimeWeight);
+          return delta < 0 ? -1 : (delta > 0 ? 1 : 0);
+        });
     int diskCount = usableDisks.size();
     int startIndex = 0;
     int groupSizeSize = (int) Math.ceil(usableDisks.size() / (double) diskGroupCount);