Convert task_spec to flatbuffers (#255)

* convert Ray to C++

* convert task_spec to flatbuffers

* fix

* it compiles

* latest

* tests are passing

* task2 -> task

* fix

* fix

* fix

* fix

* fix

* linting

* fix valgrind

* upgrade flatbuffers

* use debug mode for valgrind

* fix naming and comments

* downgrade flatbuffers

* fix linting

* reintroduce TaskSpec_free

* rename TaskSpec -> TaskInfo

* refactoring

* linting
This commit is contained in:
Philipp Moritz
2017-03-05 02:05:02 -08:00
committed by Robert Nishihara
parent 65a8659f3d
commit 0b8d279ef2
36 changed files with 1054 additions and 931 deletions
@@ -36,10 +36,10 @@ void GlobalSchedulerPolicyState_free(GlobalSchedulerPolicyState *policy_state) {
* otherwise.
*/
bool constraints_satisfied_hard(const LocalScheduler *scheduler,
const task_spec *spec) {
for (int i = 0; i < MAX_RESOURCE_INDEX; i++) {
const TaskSpec *spec) {
for (int i = 0; i < ResourceIndex_MAX; i++) {
if (scheduler->info.static_resources[i] <
task_spec_get_required_resource(spec, i)) {
TaskSpec_get_required_resource(spec, i)) {
return false;
}
}
@@ -56,7 +56,7 @@ void handle_task_round_robin(GlobalSchedulerState *state,
CHECKM(utarray_len(state->local_schedulers) > 0,
"No local schedulers. We currently don't handle this case.");
LocalScheduler *scheduler = NULL;
task_spec *task_spec = Task_task_spec(task);
TaskSpec *task_spec = Task_task_spec(task);
int i;
int num_retries = 1;
bool task_satisfied = false;
@@ -83,22 +83,22 @@ void handle_task_round_robin(GlobalSchedulerState *state,
}
ObjectSizeEntry *create_object_size_hashmap(GlobalSchedulerState *state,
task_spec *task_spec,
TaskSpec *task_spec,
bool *has_args_by_ref,
int64_t *task_data_size) {
ObjectSizeEntry *s = NULL, *object_size_table = NULL;
*task_data_size = 0;
for (int i = 0; i < task_num_args(task_spec); i++) {
for (int i = 0; i < TaskSpec_num_args(task_spec); i++) {
/* Object ids are only available for args by references.
* Args by value are serialized into the task_spec itself.
* Args by value are serialized into the TaskSpec itself.
* We will only concern ourselves with args by ref for data size calculation
*/
if (task_arg_type(task_spec, i) != ARG_BY_REF) {
if (!TaskSpec_arg_by_ref(task_spec, i)) {
continue;
}
*has_args_by_ref = true;
ObjectID obj_id = task_arg_id(task_spec, i);
ObjectID obj_id = TaskSpec_arg_id(task_spec, i);
/* Look up this object ID in the global scheduler object cache. */
SchedulerObjectInfo *obj_info_entry = NULL;
HASH_FIND(hh, state->scheduler_object_info_table, &obj_id, sizeof(obj_id),
@@ -245,14 +245,14 @@ double calculate_object_size_fraction(GlobalSchedulerState *state,
double calculate_score_dynvec_normalized(GlobalSchedulerState *state,
LocalScheduler *scheduler,
const task_spec *task_spec,
const TaskSpec *task_spec,
double object_size_fraction) {
/* The object size fraction is now calculated for this (task,node) pair. */
/* Construct the normalized dynamic resource attribute vector */
double normalized_dynvec[MAX_RESOURCE_INDEX + 1];
double normalized_dynvec[ResourceIndex_MAX + 1];
memset(&normalized_dynvec, 0, sizeof(normalized_dynvec));
for (int i = 0; i < MAX_RESOURCE_INDEX; i++) {
double resreqval = task_spec_get_required_resource(task_spec, i);
for (int i = 0; i < ResourceIndex_MAX; i++) {
double resreqval = TaskSpec_get_required_resource(task_spec, i);
if (resreqval <= 0) {
/* Skip and leave normalized dynvec value == 0. */
continue;
@@ -260,12 +260,12 @@ double calculate_score_dynvec_normalized(GlobalSchedulerState *state,
normalized_dynvec[i] =
MIN(1, scheduler->info.dynamic_resources[i] / resreqval);
}
normalized_dynvec[MAX_RESOURCE_INDEX] = object_size_fraction;
normalized_dynvec[ResourceIndex_MAX] = object_size_fraction;
/* Finally, calculate the score. */
double score = inner_product(normalized_dynvec,
state->policy_state->resource_attribute_weight,
MAX_RESOURCE_INDEX + 1);
ResourceIndex_MAX + 1);
return score;
}
@@ -278,7 +278,7 @@ double calculate_cost_pending(const GlobalSchedulerState *state,
bool handle_task_waiting(GlobalSchedulerState *state,
GlobalSchedulerPolicyState *policy_state,
Task *task) {
task_spec *task_spec = Task_task_spec(task);
TaskSpec *task_spec = Task_task_spec(task);
CHECKM(task_spec != NULL,
"task wait handler encounted a task with NULL spec");