xleoken commented on code in PR #2119:
URL:
https://github.com/apache/incubator-celeborn/pull/2119#discussion_r1458719879
##########
master/src/main/scala/org/apache/celeborn/service/deploy/master/Master.scala:
##########
@@ -678,16 +679,9 @@ private[celeborn] class Master(
if (requestSlots.maxWorkers <= 0) slotsAssignMaxWorkers
else Math.min(slotsAssignMaxWorkers, requestSlots.maxWorkers)),
numAvailableWorkers)
- val startIndex = Random.nextInt(numAvailableWorkers)
- val selectedWorkers = new util.ArrayList[WorkerInfo](numWorkers)
- selectedWorkers.addAll(availableWorkers.subList(
- startIndex,
- Math.min(numAvailableWorkers, startIndex + numWorkers)))
- if (startIndex + numWorkers > numAvailableWorkers) {
- selectedWorkers.addAll(availableWorkers.subList(
- 0,
- startIndex + numWorkers - numAvailableWorkers))
- }
+ Collections.rotate(availableWorkers, Random.nextInt(numAvailableWorkers))
Review Comment:
> When allocate, it will start from a random index of worker. IMO it's fine.
Refer to
https://github.com/apache/incubator-celeborn/blob/main/master/src/main/java/org/apache/celeborn/service/deploy/master/SlotsAllocator.java#L339
Right, the SlotsAllocator use a random index of workers, it start from
selected workers).
If the client set the num of `requestSlots.maxWorkers` less then the num of
all wokers, the master will always choose the top workers.
##########
master/src/main/scala/org/apache/celeborn/service/deploy/master/Master.scala:
##########
@@ -678,16 +679,9 @@ private[celeborn] class Master(
if (requestSlots.maxWorkers <= 0) slotsAssignMaxWorkers
else Math.min(slotsAssignMaxWorkers, requestSlots.maxWorkers)),
numAvailableWorkers)
- val startIndex = Random.nextInt(numAvailableWorkers)
- val selectedWorkers = new util.ArrayList[WorkerInfo](numWorkers)
- selectedWorkers.addAll(availableWorkers.subList(
- startIndex,
- Math.min(numAvailableWorkers, startIndex + numWorkers)))
- if (startIndex + numWorkers > numAvailableWorkers) {
- selectedWorkers.addAll(availableWorkers.subList(
- 0,
- startIndex + numWorkers - numAvailableWorkers))
- }
+ Collections.rotate(availableWorkers, Random.nextInt(numAvailableWorkers))
Review Comment:
> When allocate, it will start from a random index of worker. IMO it's fine.
Refer to
https://github.com/apache/incubator-celeborn/blob/main/master/src/main/java/org/apache/celeborn/service/deploy/master/SlotsAllocator.java#L339
Right, the SlotsAllocator use a random index of workers, it start from
selected workers.
If the client set the num of `requestSlots.maxWorkers` less then the num of
all wokers, the master will always choose the top workers.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]