aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject incubator-aurora git commit: Offer filtering for static vetoes. Part 4 of 4: Benchmarks.
Date Tue, 24 Feb 2015 21:43:04 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master d93b863cc -> cd681d9e0


Offer filtering for static vetoes. Part 4 of 4: Benchmarks.

Reviewed at https://reviews.apache.org/r/30895/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/cd681d9e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/cd681d9e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/cd681d9e

Branch: refs/heads/master
Commit: cd681d9e0701e2197b7731042eadc4b029145528
Parents: d93b863
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Tue Feb 24 13:41:54 2015 -0800
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Tue Feb 24 13:41:54 2015 -0800

----------------------------------------------------------------------
 .../aurora/benchmark/BenchmarkSettings.java     | 115 ++++++++++++++
 .../aurora/benchmark/SchedulingBenchmarks.java  | 149 ++++++++-----------
 .../java/org/apache/aurora/benchmark/Tasks.java |  15 +-
 3 files changed, 188 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/cd681d9e/src/jmh/java/org/apache/aurora/benchmark/BenchmarkSettings.java
----------------------------------------------------------------------
diff --git a/src/jmh/java/org/apache/aurora/benchmark/BenchmarkSettings.java b/src/jmh/java/org/apache/aurora/benchmark/BenchmarkSettings.java
new file mode 100644
index 0000000..8f43bd7
--- /dev/null
+++ b/src/jmh/java/org/apache/aurora/benchmark/BenchmarkSettings.java
@@ -0,0 +1,115 @@
+/**
+ * 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 org.apache.aurora.benchmark;
+
+import java.util.Set;
+
+import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
+import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Benchmark test settings.
+ */
+final class BenchmarkSettings {
+  private final Set<IHostAttributes> hostAttributes;
+  private final double clusterUtilization;
+  private final boolean allVictimsEligibleForPreemption;
+  private final IScheduledTask task;
+
+  private BenchmarkSettings(
+      double clusterUtilization,
+      boolean allVictimsEligibleForPreemption,
+      Set<IHostAttributes> hostAttributes,
+      IScheduledTask task) {
+
+    this.clusterUtilization = clusterUtilization;
+    this.allVictimsEligibleForPreemption = allVictimsEligibleForPreemption;
+    this.hostAttributes = requireNonNull(hostAttributes);
+    this.task = requireNonNull(task);
+  }
+
+  /**
+   * Gets the cluster utilization factor specifying what percentage of hosts in the cluster
+   * already have tasks assigned to them.
+   *
+   * @return Cluster utilization (default: 0.9).
+   */
+  double getClusterUtilization() {
+    return clusterUtilization;
+  }
+
+  /**
+   * Flag indicating whether all existing assigned tasks are available for preemption.
+   *
+   * @return Victim preemption eligibility (default: false).
+   */
+  boolean areAllVictimsEligibleForPreemption() {
+    return allVictimsEligibleForPreemption;
+  }
+
+  /**
+   * Gets a set of cluster host attributes.
+   *
+   * @return Set of {@link IHostAttributes}.
+   */
+  Set<IHostAttributes> getHostAttributes() {
+    return hostAttributes;
+  }
+
+  /**
+   * Gets a benchmark task.
+   *
+   * @return Task to run a benchmark for.
+   */
+  IScheduledTask getTask() {
+    return task;
+  }
+
+  static class Builder {
+    private double clusterUtilization = 0.9;
+    private boolean allVictimsEligibleForPreemption;
+    private Set<IHostAttributes> hostAttributes;
+    private IScheduledTask task;
+
+    Builder setClusterUtilization(double newClusterUtilization) {
+      clusterUtilization = newClusterUtilization;
+      return this;
+    }
+
+    Builder setVictimPreemptionEligibilty(boolean newPreemptionEligibility) {
+      allVictimsEligibleForPreemption = newPreemptionEligibility;
+      return this;
+    }
+
+    Builder setHostAttributes(Set<IHostAttributes> newHostAttributes) {
+      hostAttributes = newHostAttributes;
+      return this;
+    }
+
+    Builder setTask(IScheduledTask newTask) {
+      task = newTask;
+      return this;
+    }
+
+    BenchmarkSettings build() {
+      return new BenchmarkSettings(
+          clusterUtilization,
+          allVictimsEligibleForPreemption,
+          hostAttributes,
+          task);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/cd681d9e/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java
----------------------------------------------------------------------
diff --git a/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java b/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java
index bacfbfe..0351b10 100644
--- a/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java
+++ b/src/jmh/java/org/apache/aurora/benchmark/SchedulingBenchmarks.java
@@ -77,13 +77,11 @@ public class SchedulingBenchmarks {
    */
   @State(Scope.Thread)
   public abstract static class AbstractBase {
-    protected Storage storage;
-    protected TaskScheduler taskScheduler;
-    protected OfferManager offerManager;
-    protected IScheduledTask task;
-    protected Set<HostOffer> offers;
-    protected Set<IHostAttributes> hostAttributes;
-    protected EventBus eventBus;
+    private Storage storage;
+    private TaskScheduler taskScheduler;
+    private OfferManager offerManager;
+    private EventBus eventBus;
+    private BenchmarkSettings settings;
 
     /**
      * Runs once to setup up benchmark state.
@@ -160,20 +158,26 @@ public class SchedulingBenchmarks {
       offerManager = injector.getInstance(OfferManager.class);
       eventBus.register(injector.getInstance(CachedClusterState.class));
 
-      hostAttributes = createHostAttributes();
-      saveHostAttributes(hostAttributes);
+      settings = getSettings();
+      saveHostAttributes(settings.getHostAttributes());
 
-      offers = createOffers(hostAttributes);
+      Set<HostOffer> offers = new Offers.Builder().build(settings.getHostAttributes());
       Offers.addOffers(offerManager, offers);
-      fillUpCluster();
+      fillUpCluster(offers.size());
 
-      task = createTask();
-      saveTasks(ImmutableSet.of(task));
+      saveTasks(ImmutableSet.of(settings.getTask()));
     }
 
-    private void fillUpCluster() {
-      int numOffersToFill = (int) Math.round(offers.size() * getClusterUtilization());
-      Set<IScheduledTask> tasksToAssign = new Tasks.Builder().build(numOffersToFill);
+    private Set<IScheduledTask> buildClusterTasks(int numOffers) {
+      int numOffersToFill = (int) Math.round(numOffers * settings.getClusterUtilization());
+      return new Tasks.Builder()
+          .setRole("victim")
+          .setProduction(!settings.areAllVictimsEligibleForPreemption())
+          .build(numOffersToFill);
+    }
+
+    private void fillUpCluster(int numOffers) {
+      Set<IScheduledTask> tasksToAssign = buildClusterTasks(numOffers);
       saveTasks(tasksToAssign);
       for (IScheduledTask scheduledTask : tasksToAssign) {
         taskScheduler.schedule(scheduledTask.getAssignedTask().getTaskId());
@@ -200,13 +204,7 @@ public class SchedulingBenchmarks {
       });
     }
 
-    protected abstract double getClusterUtilization();
-
-    protected abstract Set<IHostAttributes> createHostAttributes();
-
-    protected abstract Set<HostOffer> createOffers(Set<IHostAttributes> attributes);
-
-    protected abstract IScheduledTask createTask();
+    protected abstract BenchmarkSettings getSettings();
 
     /**
      * Benchmark entry point. All settings (e.g. iterations, benchmarkMode and etc.) are
defined
@@ -217,7 +215,7 @@ public class SchedulingBenchmarks {
      */
     @Benchmark
     public boolean runBenchmark() {
-      return taskScheduler.schedule(task.getAssignedTask().getTaskId());
+      return taskScheduler.schedule(settings.getTask().getAssignedTask().getTaskId());
     }
   }
 
@@ -226,56 +224,46 @@ public class SchedulingBenchmarks {
    */
   public static class InsufficientResourcesSchedulingBenchmark extends AbstractBase {
     @Override
-    protected Set<IHostAttributes> createHostAttributes() {
-      return new Hosts.Builder().setNumHostsPerRack(2).build(1000);
-    }
-
-    @Override
-    protected Set<HostOffer> createOffers(Set<IHostAttributes> hostAttributes)
{
-      return new Offers.Builder().build(hostAttributes);
-    }
-
-    @Override
-    protected double getClusterUtilization() {
-      return 0.9;
-    }
-
-    @Override
-    protected IScheduledTask createTask() {
-      return Iterables.getOnlyElement(new Tasks.Builder()
-          .setProduction(true)
-          .setCpu(32)
-          .setTaskIdFormat("test-%s")
-          .build(1));
+    protected BenchmarkSettings getSettings() {
+      return new BenchmarkSettings.Builder()
+          .setHostAttributes(new Hosts.Builder().setNumHostsPerRack(2).build(1000))
+          .setTask(Iterables.getOnlyElement(new Tasks.Builder()
+              .setProduction(true)
+              .setCpu(32)
+              .setTaskIdFormat("test-%s")
+              .build(1))).build();
     }
   }
 
   /**
-   * Tests scheduling performance with a task vetoed due to constraint mismatch.
+   * Tests scheduling performance with a task vetoed due to value constraint mismatch.
    */
-  public static class ConstraintMismatchsSchedulingBenchmark extends AbstractBase {
-    @Override
-    protected Set<IHostAttributes> createHostAttributes() {
-      return new Hosts.Builder().setNumHostsPerRack(2).build(1000);
-    }
-
-    @Override
-    protected Set<HostOffer> createOffers(Set<IHostAttributes> hostAttributes)
{
-      return new Offers.Builder().build(hostAttributes);
-    }
-
+  public static class ValueConstraintMismatchSchedulingBenchmark extends AbstractBase {
     @Override
-    protected double getClusterUtilization() {
-      return 0.9;
+    protected BenchmarkSettings getSettings() {
+      return new BenchmarkSettings.Builder()
+          .setHostAttributes(new Hosts.Builder().setNumHostsPerRack(2).build(1000))
+          .setTask(Iterables.getOnlyElement(new Tasks.Builder()
+              .setProduction(true)
+              .addValueConstraint("host", "denied")
+              .setTaskIdFormat("test-%s")
+              .build(1))).build();
     }
+  }
 
+  /**
+   * Tests scheduling performance with a task vetoed due to limit constraint mismatch.
+   */
+  public static class LimitConstraintMismatchSchedulingBenchmark extends AbstractBase {
     @Override
-    protected IScheduledTask createTask() {
-      return Iterables.getOnlyElement(new Tasks.Builder()
-          .setProduction(true)
-          .addValueConstraint("host", "denied")
-          .setTaskIdFormat("test-%s")
-          .build(1));
+    protected BenchmarkSettings getSettings() {
+      return new BenchmarkSettings.Builder()
+          .setHostAttributes(new Hosts.Builder().setNumHostsPerRack(2).build(1000))
+          .setTask(Iterables.getOnlyElement(new Tasks.Builder()
+              .setProduction(true)
+              .addLimitConstraint("host", 0)
+              .setTaskIdFormat("test-%s")
+              .build(1))).build();
     }
   }
 
@@ -285,27 +273,16 @@ public class SchedulingBenchmarks {
    */
   public static class PreemptorFallbackForLargeClusterBenchmark extends AbstractBase {
     @Override
-    protected Set<IHostAttributes> createHostAttributes() {
-      return new Hosts.Builder().setNumHostsPerRack(2).build(10000);
-    }
-
-    @Override
-    protected Set<HostOffer> createOffers(Set<IHostAttributes> hostAttributes)
{
-      return new Offers.Builder().build(hostAttributes);
-    }
-
-    @Override
-    protected double getClusterUtilization() {
-      return 1.0;
-    }
-
-    @Override
-    protected IScheduledTask createTask() {
-      return Iterables.getOnlyElement(new Tasks.Builder()
-          .setProduction(true)
-          .addValueConstraint("host", "denied")
-          .setTaskIdFormat("test-%s")
-          .build(1));
+    protected BenchmarkSettings getSettings() {
+      return new BenchmarkSettings.Builder()
+          .setClusterUtilization(1.0)
+          .setVictimPreemptionEligibilty(true)
+          .setHostAttributes(new Hosts.Builder().setNumHostsPerRack(2).build(10000))
+          .setTask(Iterables.getOnlyElement(new Tasks.Builder()
+              .setProduction(true)
+              .addLimitConstraint("host", 0)
+              .setTaskIdFormat("test-%s")
+              .build(1))).build();
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/cd681d9e/src/jmh/java/org/apache/aurora/benchmark/Tasks.java
----------------------------------------------------------------------
diff --git a/src/jmh/java/org/apache/aurora/benchmark/Tasks.java b/src/jmh/java/org/apache/aurora/benchmark/Tasks.java
index 1a35f9e..491c687 100644
--- a/src/jmh/java/org/apache/aurora/benchmark/Tasks.java
+++ b/src/jmh/java/org/apache/aurora/benchmark/Tasks.java
@@ -46,9 +46,9 @@ final class Tasks {
    * Builds tasks for the specified configuration.
    */
   static final class Builder {
-    private static final JobKey JOB_KEY = new JobKey("jmh", "dev", "benchmark");
     private static final String USER_FORMAT = "user-%s";
 
+    private JobKey jobKey = new JobKey("jmh", "dev", "benchmark");
     private String taskIdFormat = "default_task-%s";
     private boolean isProduction = false;
     private double cpu = 6.0;
@@ -57,6 +57,11 @@ final class Tasks {
     private ScheduleStatus scheduleStatus = ScheduleStatus.PENDING;
     private ImmutableSet.Builder<Constraint> constraints = ImmutableSet.builder();
 
+    Builder setRole(String newRole) {
+      jobKey.setRole(newRole);
+      return this;
+    }
+
     Builder setTaskIdFormat(String newTaskIdFormat) {
       taskIdFormat = newTaskIdFormat;
       return this;
@@ -131,11 +136,11 @@ final class Tasks {
                     .setDiskMb(disk.as(Data.MB))
                     .setProduction(isProduction)
                     .setRequestedPorts(ImmutableSet.<String>of())
-                    .setJob(JOB_KEY)
-                    .setJobName(JOB_KEY.getName())
-                    .setEnvironment(JOB_KEY.getEnvironment())
+                    .setJob(jobKey)
+                    .setJobName(jobKey.getName())
+                    .setEnvironment(jobKey.getEnvironment())
                     .setOwner(new Identity()
-                        .setRole(JOB_KEY.getRole())
+                        .setRole(jobKey.getRole())
                         .setUser(String.format(USER_FORMAT, taskId)))))));
       }
 


Mime
View raw message