mirror of
https://github.com/wassname/ray.git
synced 2026-07-14 11:17:54 +08:00
Convert actor dummy objects to task execution edges. (#1281)
* Define execution dependencies flatbuffer and add to Redis commands * Convert TaskSpec to TaskExecutionSpec * Add execution dependencies to Python bindings * Submitting actor tasks uses execution dependency API instead of dummy argument * Fix dependency getters and some cleanup for fetching missing dependencies * C++ convention * Make TaskExecutionSpec a C++ class * Convert local scheduler to use TaskExecutionSpec class * Convert some pointers to references * Finish conversion to TaskExecutionSpec class * fix * Fix * Fix memory errors? * Cast flatbuffers GetSize to size_t * Fixes * add more retries in global scheduler unit test * fix linting and cast fbb.GetSize to size_t * Style and doc * Fix linting and simplify from_flatbuf.
This commit is contained in:
committed by
Robert Nishihara
parent
cac5f47600
commit
12fdb3f53a
@@ -7,10 +7,10 @@ extern TaskBuilder *g_task_builder;
|
||||
|
||||
const int64_t arg_value_size = 1000;
|
||||
|
||||
static inline TaskSpec *example_task_spec_with_args(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
ObjectID arg_ids[],
|
||||
int64_t *task_spec_size) {
|
||||
static inline TaskExecutionSpec example_task_execution_spec_with_args(
|
||||
int64_t num_args,
|
||||
int64_t num_returns,
|
||||
ObjectID arg_ids[]) {
|
||||
TaskID parent_task_id = globally_unique_id();
|
||||
FunctionID func_id = globally_unique_id();
|
||||
TaskSpec_start_construct(g_task_builder, NIL_ID, parent_task_id, 0,
|
||||
@@ -25,36 +25,53 @@ static inline TaskSpec *example_task_spec_with_args(int64_t num_args,
|
||||
}
|
||||
TaskSpec_args_add_ref(g_task_builder, &arg_id, 1);
|
||||
}
|
||||
return TaskSpec_finish_construct(g_task_builder, task_spec_size);
|
||||
int64_t task_spec_size;
|
||||
TaskSpec *spec = TaskSpec_finish_construct(g_task_builder, &task_spec_size);
|
||||
std::vector<ObjectID> execution_dependencies;
|
||||
auto execution_spec =
|
||||
TaskExecutionSpec(execution_dependencies, spec, task_spec_size);
|
||||
TaskSpec_free(spec);
|
||||
return execution_spec;
|
||||
}
|
||||
|
||||
static inline TaskSpec *example_task_spec(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
int64_t *task_spec_size) {
|
||||
return example_task_spec_with_args(num_args, num_returns, NULL,
|
||||
task_spec_size);
|
||||
static inline TaskExecutionSpec example_task_execution_spec(
|
||||
int64_t num_args,
|
||||
int64_t num_returns) {
|
||||
return example_task_execution_spec_with_args(num_args, num_returns, NULL);
|
||||
}
|
||||
|
||||
static inline Task *example_task_with_args(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
int task_state,
|
||||
ObjectID arg_ids[]) {
|
||||
int64_t task_spec_size;
|
||||
TaskSpec *spec = example_task_spec_with_args(num_args, num_returns, arg_ids,
|
||||
&task_spec_size);
|
||||
Task *instance = Task_alloc(spec, task_spec_size, task_state, NIL_ID);
|
||||
TaskSpec_free(spec);
|
||||
TaskExecutionSpec spec =
|
||||
example_task_execution_spec_with_args(num_args, num_returns, arg_ids);
|
||||
Task *instance = Task_alloc(spec, task_state, NIL_ID);
|
||||
return instance;
|
||||
}
|
||||
|
||||
static inline Task *example_task(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
int task_state) {
|
||||
int64_t task_spec_size;
|
||||
TaskSpec *spec = example_task_spec(num_args, num_returns, &task_spec_size);
|
||||
Task *instance = Task_alloc(spec, task_spec_size, task_state, NIL_ID);
|
||||
TaskSpec_free(spec);
|
||||
TaskExecutionSpec spec = example_task_execution_spec(num_args, num_returns);
|
||||
Task *instance = Task_alloc(spec, task_state, NIL_ID);
|
||||
return instance;
|
||||
}
|
||||
|
||||
static inline bool Task_equals(Task *task1, Task *task2) {
|
||||
if (task1->state != task2->state) {
|
||||
return false;
|
||||
}
|
||||
if (!DBClientID_equal(task1->local_scheduler_id, task2->local_scheduler_id)) {
|
||||
return false;
|
||||
}
|
||||
auto execution_spec1 = Task_task_execution_spec(task1);
|
||||
auto execution_spec2 = Task_task_execution_spec(task2);
|
||||
if (execution_spec1->SpecSize() != execution_spec2->SpecSize()) {
|
||||
return false;
|
||||
}
|
||||
return memcmp(execution_spec1->Spec(), execution_spec2->Spec(),
|
||||
execution_spec1->SpecSize()) == 0;
|
||||
}
|
||||
|
||||
#endif /* EXAMPLE_TASK_H */
|
||||
|
||||
Reference in New Issue
Block a user