Github user kayousterhout commented on a diff in the pull request:
https://github.com/apache/spark/pull/16053#discussion_r93091673
--- Diff:
core/src/main/scala/org/apache/spark/scheduler/TaskDescription.scala ---
@@ -17,27 +17,119 @@
package org.apache.spark.scheduler
+import java.io.{DataInputStream, DataOutputStream}
import java.nio.ByteBuffer
+import java.util.Properties
-import org.apache.spark.util.SerializableBuffer
+import scala.collection.mutable.{HashMap, Map}
+
+import org.apache.spark.util.{ByteBufferInputStream,
ByteBufferOutputStream, Utils}
/**
* Description of a task that gets passed onto executors to be executed,
usually created by
- * `TaskSetManager.resourceOffer`.
+ * `TaskSetManager.resourceOffer`.
+ *
+ * TaskDescriptions and the associated Task need to be serialized
carefully for two reasons:
+ *
+ * (1) When a TaskDescription is received by an Executor, the Executor
needs to first get the
+ * list of JARs and files and add these to the classpath, and set
the properties, before
+ * deserializing the Task object (serializedTask). This is why the
Properties are included
+ * in the TaskDescription, even though they're also in the
serialized task.
+ * (2) Because a TaskDescription is serialized and sent to an executor
for each task, efficient
+ * serialization (both in terms of serialization time and
serialized buffer size) is
+ * important. For this reason, we serialize TaskDescriptions
ourselves with the
+ * TaskDescription.encode and TaskDescription.decode methods.
This results in a smaller
+ * serialized size because it avoids serializing unnecessary
fields in the Map objects
+ * (which can introduce significant overhead when the maps are
small).
--- End diff --
Oh this is a great point, and I realize this is likely also the explanation
for the ~2% remaining performance disparity between this change and #15505 that
I mentioned in my comment. Thanks for noticing this oversight -- I'll fix this!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]