Skip to content

Commit

Permalink
remove from the data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
JinZhou5042 committed Feb 5, 2025
1 parent 76421a2 commit dbf2360
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 39 deletions.
32 changes: 0 additions & 32 deletions taskvine/src/manager/vine_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -2835,36 +2835,6 @@ static vine_result_code_t start_one_task(struct vine_manager *q, struct vine_wor
return result;
}

/* Check if any of the resources is overcommitted on a given worker. */
static int is_resource_committable(struct vine_manager *q, struct vine_resource resource)
{
return resource.inuse < overcommitted_resource_total(q, resource.total);
}
static int worker_has_free_resources(struct vine_manager *q, struct vine_worker_info *w)
{
/* If any slots are committable */
uint64_t task_id;
struct vine_task *t;
ITABLE_ITERATE(w->current_libraries, task_id, t)
{
if (t->function_slots_inuse < t->function_slots_total) {
return 1;
}
}

/* If both memory and disk are committable */
if (is_resource_committable(q, w->resources->memory) && is_resource_committable(q, w->resources->disk)) {
/* Return true if either cores or GPUs are defined and committable. */
if ((w->resources->cores.total > 0 && is_resource_committable(q, w->resources->cores)) ||
(w->resources->gpus.total > 0 && is_resource_committable(q, w->resources->gpus))) {
return 1;
}
}

/* If reach here, no free resources on this worker */
return 0;
}

static void count_worker_resources(struct vine_manager *q, struct vine_worker_info *w)
{
w->resources->cores.inuse = 0;
Expand Down Expand Up @@ -2902,8 +2872,6 @@ static void count_worker_resources(struct vine_manager *q, struct vine_worker_in
}

w->resources->disk.inuse += ceil(BYTES_TO_MEGABYTES(w->inuse_cache));

w->has_free_resources = worker_has_free_resources(q, w);
}

static void update_max_worker(struct vine_manager *q, struct vine_worker_info *w)
Expand Down
50 changes: 45 additions & 5 deletions taskvine/src/manager/vine_schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,46 @@ int check_worker_have_enough_disk_with_inputs(struct vine_manager *q, struct vin
return ok;
}

/* Check if any of the resources is defined and committable on a given worker.
* @param q Manager info structure
* @param resource @vine_resources.h:struct vine_resources
* @return 1 if the resource type is defined and can be allocated to a task, 0 otherwise.
*/
static int is_resource_committable(struct vine_manager *q, struct vine_resource resource)
{
return resource.total > 0 && resource.inuse < overcommitted_resource_total(q, resource.total);
}

/* Check if this worker has committable resources for any type of task.
* If it returns false, neither a function task, library task nor a regular task can run on this worker.
* If it returns true, the worker has either free slots for function calls or sufficient resources for regular tasks.
* @param q Manager info structure
* @param w The worker info structure.
*/
static int check_worker_have_committable_resources(struct vine_manager *q, struct vine_worker_info *w)
{
/* If any slots are committable */
uint64_t task_id;
struct vine_task *t;
ITABLE_ITERATE(w->current_libraries, task_id, t)
{
if (t->function_slots_inuse < t->function_slots_total) {
return 1;
}
}

/* A regular task has to use both memory and disk */
if (is_resource_committable(q, w->resources->memory) && is_resource_committable(q, w->resources->disk)) {
/* If either cores or gpus are committable. */
if (is_resource_committable(q, w->resources->cores) || is_resource_committable(q, w->resources->gpus)) {
return 1;
}
}

/* If reach here, no free resources on this worker */
return 0;
}

/* Check if this task is compatible with this given worker by considering
* resources availability, features, blocklist, and all other relevant factors.
* Used by all scheduling methods for basic compatibility.
Expand All @@ -156,11 +196,6 @@ int check_worker_against_task(struct vine_manager *q, struct vine_worker_info *w
return 0;
}

/* if worker has free resources to use */
if (!w->has_free_resources) {
return 0;
}

/* Don't send tasks to this worker if it is in draining mode (no more tasks). */
if (w->draining) {
return 0;
Expand Down Expand Up @@ -189,6 +224,11 @@ int check_worker_against_task(struct vine_manager *q, struct vine_worker_info *w
return 0;
}

/* if worker has free resources to use */
if (!check_worker_have_committable_resources(q, w)) {
return 0;
}

/* Compute the resources to allocate to this task. */
struct rmsummary *l = vine_manager_choose_resources_for_task(q, w, t);

Expand Down
1 change: 0 additions & 1 deletion taskvine/src/manager/vine_worker_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ struct vine_worker_info *vine_worker_create(struct link *lnk)
w->version = strdup("unknown");
w->factory_name = 0;
w->workerid = 0;
w->has_free_resources = 0;

w->resources = vine_resources_create();
w->features = hash_table_create(4, 0);
Expand Down
1 change: 0 additions & 1 deletion taskvine/src/manager/vine_worker_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ struct vine_worker_info {
int64_t total_bytes_transferred;
int forsaken_tasks;
int64_t inuse_cache;
int has_free_resources;

timestamp_t total_task_time;
timestamp_t total_transfer_time;
Expand Down

0 comments on commit dbf2360

Please sign in to comment.