johnyangk commented on a change in pull request #72: [Nemo-59] Skewed data-aware executor allocation URL: https://github.com/apache/incubator-nemo/pull/72#discussion_r200861359
########## File path: runtime/master/src/main/java/edu/snu/nemo/runtime/master/scheduler/SkewnessAwareSchedulingConstraint.java ########## @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2018 Seoul National University + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.snu.nemo.runtime.master.scheduler; + +import com.google.common.annotations.VisibleForTesting; +import edu.snu.nemo.common.ir.executionproperty.AssociatedProperty; +import edu.snu.nemo.common.ir.vertex.executionproperty.SkewnessAwareSchedulingProperty; +import edu.snu.nemo.runtime.common.RuntimeIdGenerator; +import edu.snu.nemo.runtime.common.data.HashRange; +import edu.snu.nemo.runtime.common.data.KeyRange; +import edu.snu.nemo.runtime.common.plan.StageEdge; +import edu.snu.nemo.runtime.common.plan.Task; +import edu.snu.nemo.runtime.master.resource.ExecutorRepresenter; +import org.apache.reef.annotations.audience.DriverSide; + +import javax.annotation.concurrent.ThreadSafe; +import javax.inject.Inject; + +/** + * This policy aims to distribute partitions with skewed keys to different executors. + */ +@ThreadSafe +@DriverSide +@AssociatedProperty(SkewnessAwareSchedulingProperty.class) +public final class SkewnessAwareSchedulingConstraint implements SchedulingConstraint { + + @VisibleForTesting + @Inject + public SkewnessAwareSchedulingConstraint() { + } + + public boolean hasSkewedData(final Task task) { + final int taskIdx = RuntimeIdGenerator.getIndexFromTaskId(task.getTaskId()); + for (StageEdge inEdge : task.getTaskIncomingEdges()) { + final KeyRange hashRange = inEdge.getTaskIdxToKeyRange().get(taskIdx); + if (((HashRange) hashRange).isSkewed()) { Review comment: Instead of introducing isSkewed(), can we determine here whether this key range is 'skewed' or not? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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
