Skip to content

Commit

Permalink
change group hash table to itable
Browse files Browse the repository at this point in the history
  • Loading branch information
colinthomas-z80 committed Jan 22, 2025
1 parent d1945f7 commit 673ae06
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions taskvine/src/manager/vine_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -2997,7 +2997,7 @@ static vine_result_code_t commit_task_group_to_worker(struct vine_manager *q, st

struct list *l = NULL;
if (t->group_id) {
l = hash_table_lookup(q->task_group_table, t->group_id);
l = itable_lookup(q->task_group_table, t->group_id);
list_remove(l, t);
// decrement refcount
vine_task_delete(t);
Expand Down Expand Up @@ -3328,7 +3328,7 @@ static void vine_manager_consider_recovery_task(struct vine_manager *q, struct v
return;

/* Do not try to group recovery tasks */
rt->group_id = NULL;
rt->group_id = 0;

switch (rt->state) {
case VINE_TASK_INITIAL:
Expand Down Expand Up @@ -3995,7 +3995,7 @@ struct vine_manager *vine_ssl_create(int port, const char *key, const char *cert

q->factory_table = hash_table_create(0, 0);
q->current_transfer_table = hash_table_create(0, 0);
q->task_group_table = hash_table_create(0, 0);
q->task_group_table = itable_create(0);
q->group_id_counter = 1;
q->fetch_factory = 0;

Expand Down Expand Up @@ -4342,7 +4342,7 @@ void vine_delete(struct vine_manager *q)
hash_table_delete(q->current_transfer_table);

vine_task_groups_clear(q);
hash_table_delete(q->task_group_table);
itable_delete(q->task_group_table);

itable_clear(q->tasks, (void *)delete_task_at_exit);
itable_delete(q->tasks);
Expand Down Expand Up @@ -5537,11 +5537,11 @@ int vine_cancel_by_task_id(struct vine_manager *q, int task_id)
}

if (task->group_id) {
struct list *l = hash_table_lookup(q->task_group_table, task->group_id);
struct list *l = itable_lookup(q->task_group_table, task->group_id);
if (l) {
list_remove(l, task);
}
task->group_id = NULL;
task->group_id = 0;
vine_task_delete(task);
}

Expand Down
2 changes: 1 addition & 1 deletion taskvine/src/manager/vine_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ struct vine_manager {
struct hash_table *workers_with_watched_file_updates; /* Maps link -> vine_worker_info */
struct hash_table *workers_with_complete_tasks; /* Maps link -> vine_worker_info */
struct hash_table *current_transfer_table; /* Maps uuid -> struct transfer_pair */
struct hash_table *task_group_table; /* Maps uuid -> list vine_task */
struct itable *task_group_table; /* Maps group id -> list vine_task */

/* Primary data structures for tracking files. */

Expand Down
2 changes: 1 addition & 1 deletion taskvine/src/manager/vine_manager_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ vine_result_code_t vine_manager_put_task(
}

if (t->group_id) {
vine_manager_send(q, w, "groupid %s\n", t->group_id);
vine_manager_send(q, w, "groupid %d\n", t->group_id);
}

// vine_manager_send returns the number of bytes sent, or a number less than
Expand Down
2 changes: 1 addition & 1 deletion taskvine/src/manager/vine_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ struct vine_task *vine_task_copy(const struct vine_task *task)

/* Group ID is copied. */
if (task->group_id) {
new->group_id = strdup(task->group_id);
new->group_id = task->group_id;
}

return new;
Expand Down
2 changes: 1 addition & 1 deletion taskvine/src/manager/vine_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct vine_task {
int has_fixed_locations; /**< Whether at least one file was added with the VINE_FIXED_LOCATION flag. Task fails immediately if no
worker can satisfy all the strict inputs of the task. */

char *group_id; /**< When enabled, group ID will be assigned based on temp file dependencies of this task */
int group_id; /**< When enabled, group ID will be assigned based on temp file dependencies of this task */

int refcount; /**< Number of remaining references to this object. */
};
Expand Down
14 changes: 7 additions & 7 deletions taskvine/src/manager/vine_task_groups.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ See the file COPYING for details.
// create a new task group for this task based on the temp mount file
static int vine_task_groups_create_group(struct vine_manager *q, struct vine_task *t, struct vine_mount *m)
{
char *id = string_format("%d", q->group_id_counter++);
int id = q->group_id_counter++;
struct list *l = list_create();

t->group_id = id;

struct vine_task *tc = vine_task_addref(t);

list_push_head(l, tc);
hash_table_insert(q->task_group_table, id, l);
itable_insert(q->task_group_table, id, l);
return 1;
}

// locate the group with the task which outputs the desired file, and add the new task
static int vine_task_groups_add_to_group(struct vine_manager *q, struct vine_task *t, struct vine_mount *m)
{
char *id = m->file->recovery_task->group_id;
int id = m->file->recovery_task->group_id;

if (id) {
struct list *group = hash_table_lookup(q->task_group_table, id);
struct list *group = itable_lookup(q->task_group_table, id);
t->group_id = id;
struct vine_task *tc = vine_task_addref(t);
list_push_tail(group, tc);
Expand Down Expand Up @@ -72,10 +72,10 @@ int vine_task_groups_assign_task(struct vine_manager *q, struct vine_task *t)
// could also be inputs_present && outputs_present
if (inputs_present) {
vine_task_groups_add_to_group(q, t, input_mount);
debug(D_VINE, "Assigned task to group %s", t->group_id);
debug(D_VINE, "Assigned task to group %d", t->group_id);
} else if (outputs_present) {
vine_task_groups_create_group(q, t, output_mount);
debug(D_VINE, "Create task with group %s", t->group_id);
debug(D_VINE, "Create task with group %d", t->group_id);
}

return inputs_present || outputs_present;
Expand All @@ -90,5 +90,5 @@ static void vine_task_group_delete(struct list *l)

void vine_task_groups_clear(struct vine_manager *q)
{
hash_table_clear(q->task_group_table, (void *)vine_task_group_delete);
itable_clear(q->task_group_table, (void *)vine_task_group_delete);
}

0 comments on commit 673ae06

Please sign in to comment.