Repository: ray-project/ray
File: src/ray/core_worker/core_worker.h (C/C++)

Code before:
  /// \param[in] task_id of the parent task
  /// \param[in] force_kill Whether to force kill a task by killing the worker.
  Status CancelChildren(const TaskID &task_id, bool force_kill);

  ///
  /// Private methods related to task execution. Should not be used by driver processes.
  ///

  /// Execute a task.
  ///
  /// \param task_spec[in] Task specification.
  /// \param resource_ids[in] Resource IDs of resources assigned to this
  /// worker. If nullopt, reuse the previously assigned resources.
  /// \param return_objects[out] Result objects that should be returned
  /// to the caller.
  /// \param dynamic_return_objects[out]  Result objects whose ObjectRefs were dynamically
  /// allocated during task execution by using a generator. The language-level ObjectRefs
  /// should be returned inside the statically allocated return_objects.
  /// \param borrowed_refs[out]  Refs that this task (or a nested task) was or is still
  /// borrowing. This includes all objects whose IDs we passed to the task in its
  /// arguments and recursively, any object IDs that were contained in those objects.
  /// \param is_retryable_error[out] Whether the task failed with a retryable
  /// error.
  /// \param application_error[out] The error message if the task failed during
  /// execution or cancelled.
  /// \return Status.
  Status ExecuteTask(
      const TaskSpecification &task_spec,
      std::optional<ResourceMappingType> resource_ids,
      std::vector<std::pair<ObjectID, std::shared_ptr<RayObject>>> *return_objects,
      std::vector<std::pair<ObjectID, std::shared_ptr<RayObject>>>
          *dynamic_return_objects,
      std::vector<std::pair<ObjectID, bool>> *streaming_generator_returns,
      ReferenceCounterInterface::ReferenceTableProto *borrowed_refs,
      bool *is_retryable_error,
      std::string *application_error);

  /// Put an object in the local plasma store.
  ///
  /// Return status semantics:
  /// - Status::OK(): The object was created (or already existed) and bookkeeping was
  ///   updated. Note: an internal ObjectExists from the plasma provider is treated
  ///   as OK and does not surface here.
  /// - Status::ObjectStoreFull(): The local plasma store is out of memory (or out of
  ///   disk when spilling). The error message contains context and a short memory
  ///   report.
  /// - Status::IOError(): IPC/connection failures while talking to the plasma store
  ///   (e.g., broken pipe/connection reset during shutdown, store not reachable).
  ///
  /// Call sites that run during shutdown may choose to tolerate IOError specifically,
  /// but should treat all other statuses as real failures.

Review comment (performance):
Just for my understanding, we still need to cache the value in CoreWorker because it is needed for task events right? Or is there more to it?

Code after:
  /// \param task_spec[in] Task specification.
  /// \param resource_ids[in] Resource IDs of resources assigned to this
  /// worker. If nullopt, reuse the previously assigned resources.
  /// \param return_objects[out] Result objects that should be returned
  /// to the caller.
  /// \param dynamic_return_objects[out]  Result objects whose ObjectRefs were dynamically
  /// allocated during task execution by using a generator. The language-level ObjectRefs
  /// should be returned inside the statically allocated return_objects.
  /// \param borrowed_refs[out]  Refs that this task (or a nested task) was or is still
  /// borrowing. This includes all objects whose IDs we passed to the task in its
  /// arguments and recursively, any object IDs that were contained in those objects.
  /// \param is_retryable_error[out] Whether the task failed with a retryable
  /// error.
  /// \param actor_repr_name[out] The user-specified repr name for the actor in this
  /// process if one has been set. \param application_error[out] The error message if the
  /// task failed during execution or cancelled. \return Status.
  Status ExecuteTask(
      const TaskSpecification &task_spec,
      std::optional<ResourceMappingType> resource_ids,
      std::vector<std::pair<ObjectID, std::shared_ptr<RayObject>>> *return_objects,
      std::vector<std::pair<ObjectID, std::shared_ptr<RayObject>>>
          *dynamic_return_objects,
      std::vector<std::pair<ObjectID, bool>> *streaming_generator_returns,
      ReferenceCounterInterface::ReferenceTableProto *borrowed_refs,
      bool *is_retryable_error,
      std::string *actor_repr_name,
      std::string *application_error);

  /// Put an object in the local plasma store.
  ///
  /// Return status semantics:
  /// - Status::OK(): The object was created (or already existed) and bookkeeping was
  ///   updated. Note: an internal ObjectExists from the plasma provider is treated
  ///   as OK and does not surface here.
  /// - Status::ObjectStoreFull(): The local plasma store is out of memory (or out of
  ///   disk when spilling). The error message contains context and a short memory
  ///   report.
  /// - Status::IOError(): IPC/connection failures while talking to the plasma store
  ///   (e.g., broken pipe/connection reset during shutdown, store not reachable).
  ///
  /// Call sites that run during shutdown may choose to tolerate IOError specifically,
  /// but should treat all other statuses as real failures.
  Status PutInLocalPlasmaStore(const RayObject &object,
                               const ObjectID &object_id,
                               bool pin_object);

  /// Execute a local mode task (runs normal ExecuteTask)
  ///
  /// \param spec[in] task_spec Task specification.
  std::vector<rpc::ObjectReference> ExecuteTaskLocalMode(
      const TaskSpecification &task_spec, const ActorID &actor_id = ActorID::Nil());