/// A Task represents a Ray task and a specification of its execution (e.g., /// resource demands). The task's specification contains both immutable fields, /// determined at submission time, and mutable fields, determined at execution /// time. class Task { public: /// Create a task. /// /// \param execution_spec The execution specification for the task. These are /// the mutable fields in the task specification that may change at task /// execution time. /// \param task_spec The immutable specification for the task. These fields /// are determined at task submission time. Task(const TaskExecutionSpecification &execution_spec, const TaskSpecification &task_spec) : task_execution_spec_(execution_spec), task_spec_(task_spec) {}
/// Get the task's object dependencies. This comprises the immutable task /// arguments and the mutable execution dependencies. /// /// \return The object dependencies. /// TODO(atumanov): consider returning a constant reference. conststd::vector<ObjectID> GetDependencies() const;
private: /// Task execution specification, consisting of all dynamic/mutable /// information about this task determined at execution time.. TaskExecutionSpecification task_execution_spec_; /// Task specification object, consisting of immutable information about this /// task determined at submission time. Includes resource demand, object /// dependencies, etc. TaskSpecification task_spec_; };
src/ray/raylet/task_execution_spec.h # 执行时任务规格头文件 ---------------------- namespace ray {
/// The task execution specification encapsulates all mutable information about /// the task. These fields may change at execution time, converse to the /// TaskSpecification that is determined at submission time. class TaskExecutionSpecification { public: TaskExecutionSpecification(conststd::vector<ObjectID> &&execution_dependencies); // execution_dependencies: 任务依赖 // spillback_count: 回溢次数,即由local scheduler像global scheduler推此任务的次数 TaskExecutionSpecification(conststd::vector<ObjectID> &&execution_dependencies, int spillback_count);
/// Increment the spillback count for this task. voidIncrementSpillbackCount();
/// Get the task's last timestamp (ms). /// \return The timestamp when this task was last received for scheduling. int64_t LastTimeStamp() const;
voidSetLastTimeStamp(int64_t new_timestamp);
private: /// 任务所依赖的object id的列表 std::vector<ObjectID> execution_dependencies_; /// The last time this task was received for scheduling. int64_t last_timestamp_; /// The number of times this task was spilled back by local schedulers. int spillback_count_; };