aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mehr...@apache.org
Subject aurora git commit: Fix for unnecessary object serializations
Date Sat, 29 Apr 2017 21:10:14 GMT
Repository: aurora
Updated Branches:
  refs/heads/master c85bffdd6 -> 6a896df63


Fix for unnecessary object serializations

This patch provides a fix for some unnecessary object serilizations that happen on high frequency
execution paths and contribute to scheduler's high object creation rate.

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


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

Branch: refs/heads/master
Commit: 6a896df636f2fd670d809e3c441f74c8292af4ef
Parents: c85bffd
Author: Mehrdad Nurolahzade <mehrdad@apache.org>
Authored: Fri Apr 28 15:19:36 2017 -0700
Committer: Mehrdad Nurolahzade <mnurolahzade@twitter.com>
Committed: Fri Apr 28 15:19:36 2017 -0700

----------------------------------------------------------------------
 .../apache/aurora/scheduler/events/Webhook.java |  2 +-
 .../scheduler/mesos/MesosTaskFactory.java       | 16 ++++++++------
 .../scheduler/resources/ResourceType.java       | 22 +++++++++++++-------
 .../scheduler/storage/db/DbTaskStore.java       |  2 +-
 .../scheduler/storage/mem/MemTaskStore.java     |  2 +-
 5 files changed, 28 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/6a896df6/src/main/java/org/apache/aurora/scheduler/events/Webhook.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/events/Webhook.java b/src/main/java/org/apache/aurora/scheduler/events/Webhook.java
index 3e8e38a..3868779 100644
--- a/src/main/java/org/apache/aurora/scheduler/events/Webhook.java
+++ b/src/main/java/org/apache/aurora/scheduler/events/Webhook.java
@@ -70,7 +70,7 @@ public class Webhook implements EventSubscriber {
    */
   @Subscribe
   public void taskChangedState(TaskStateChange stateChange) {
-    LOG.debug("Got an event: {}", stateChange.toString());
+    LOG.debug("Got an event: {}", stateChange);
     // Old state is not present because a scheduler just failed over. In that case we do
not want to
     // resend the entire state.
     if (stateChange.getOldState().isPresent()) {

http://git-wip-us.apache.org/repos/asf/aurora/blob/6a896df6/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java b/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
index 0d639f6..34ed820 100644
--- a/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
+++ b/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
@@ -177,9 +177,11 @@ public interface MesosTaskFactory {
       }
       Iterable<Resource> resources = acceptedOffer.getTaskResources();
 
-      LOG.debug(
-          "Setting task resources to {}",
-          Iterables.transform(resources, Protobufs::toString));
+      if (LOG.isDebugEnabled()) {
+        LOG.debug(
+            "Setting task resources to {}",
+            Iterables.transform(resources, Protobufs::toString));
+      }
 
       TaskInfo.Builder taskBuilder = TaskInfo.newBuilder()
           .setName(JobKeys.canonicalString(Tasks.getJob(task)))
@@ -334,9 +336,11 @@ public interface MesosTaskFactory {
       builder.setCommand(builder.getCommand().toBuilder().addAllUris(mesosFetcherUris));
 
       Iterable<Resource> executorResources = acceptedOffer.getExecutorResources();
-      LOG.debug(
-          "Setting executor resources to {}",
-          Iterables.transform(executorResources, Protobufs::toString));
+      if (LOG.isDebugEnabled()) {
+        LOG.debug(
+            "Setting executor resources to {}",
+            Iterables.transform(executorResources, Protobufs::toString));
+      }
       builder.clearResources().addAllResources(executorResources);
       return builder;
     }

http://git-wip-us.apache.org/repos/asf/aurora/blob/6a896df6/src/main/java/org/apache/aurora/scheduler/resources/ResourceType.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/resources/ResourceType.java b/src/main/java/org/apache/aurora/scheduler/resources/ResourceType.java
index c884284..de43eaa 100644
--- a/src/main/java/org/apache/aurora/scheduler/resources/ResourceType.java
+++ b/src/main/java/org/apache/aurora/scheduler/resources/ResourceType.java
@@ -332,7 +332,11 @@ public enum ResourceType implements TEnum {
    * @return {@link ResourceType}.
    */
   public static ResourceType fromIdValue(int value) {
-    return requireNonNull(byField.get(value), "Unmapped value: " + value);
+    ResourceType resourceType = byField.get(value);
+    if (resourceType == null) {
+      throw new NullPointerException("Unmapped value: " + value);
+    }
+    return resourceType;
   }
 
   /**
@@ -342,9 +346,11 @@ public enum ResourceType implements TEnum {
    * @return {@link ResourceType}.
    */
   public static ResourceType fromResource(IResource resource) {
-    return requireNonNull(
-        byField.get((int) resource.getSetField().getThriftFieldId()),
-        "Unknown resource: " + resource);
+    ResourceType resourceType = byField.get((int) resource.getSetField().getThriftFieldId());
+    if (resourceType == null) {
+      throw new NullPointerException("Unknown resource: " + resource);
+    }
+    return resourceType;
   }
 
   /**
@@ -354,8 +360,10 @@ public enum ResourceType implements TEnum {
    * @return {@link ResourceType}.
    */
   public static ResourceType fromResource(Resource resource) {
-    return requireNonNull(
-        BY_MESOS_NAME.get(resource.getName()),
-        "Unknown Mesos resource: " + resource);
+    ResourceType resourceType = BY_MESOS_NAME.get(resource.getName());
+    if (resourceType == null) {
+      throw new NullPointerException("Unknown Mesos resource: " + resource);
+    }
+    return resourceType;
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/6a896df6/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java
index a649a6e..5af1a79 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java
@@ -101,7 +101,7 @@ class DbTaskStore implements TaskStore.Mutable {
     String message = "Query took {} ms: {}";
     if (infoLevel) {
       LOG.info(message, time, query.get());
-    } else {
+    } else if (LOG.isDebugEnabled()) {
       LOG.debug(message, time, query.get());
     }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/6a896df6/src/main/java/org/apache/aurora/scheduler/storage/mem/MemTaskStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/mem/MemTaskStore.java b/src/main/java/org/apache/aurora/scheduler/storage/mem/MemTaskStore.java
index d89e715..964e2fc 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/mem/MemTaskStore.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/mem/MemTaskStore.java
@@ -143,7 +143,7 @@ class MemTaskStore implements TaskStore.Mutable {
     String message = "Query took {} ms: {}";
     if (infoLevel) {
       LOG.info(message, time, query.get());
-    } else {
+    } else if (LOG.isDebugEnabled()) {
       LOG.debug(message, time, query.get());
     }
 


Mime
View raw message