Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vine: round up sizes when converting bytes to other units #4088

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dttools/src/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ See the file COPYING for details.
#define TERABYTE TERA
#define PETABYTE PETA

#define BYTES_TO_STORAGE_UNIT(x, unit) (((double) x) / unit)
#define BYTES_TO_STORAGE_UNIT(x, unit) (ceil(((double) x) / unit))
#define BYTES_TO_KILOBYTES(x) BYTES_TO_STORAGE_UNIT(x, KILOBYTE)
#define BYTES_TO_MEGABYTES(x) BYTES_TO_STORAGE_UNIT(x, MEGABYTE)
#define BYTES_TO_GIGABYTES(x) BYTES_TO_STORAGE_UNIT(x, GIGABYTE)
Expand Down
4 changes: 2 additions & 2 deletions taskvine/src/manager/vine_file_replica_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ int vine_file_replica_table_insert(struct vine_manager *m, struct vine_worker_in
w->inuse_cache += replica->size;
hash_table_insert(w->current_files, cachename, replica);

double prev_available = w->resources->disk.total - ceil(BYTES_TO_MEGABYTES(w->inuse_cache + replica->size));
double prev_available = w->resources->disk.total - BYTES_TO_MEGABYTES(w->inuse_cache + replica->size);
if (prev_available >= m->current_max_worker->disk) {
/* the current worker may have been the one with the maximum available space, so we update it. */
m->current_max_worker->disk = w->resources->disk.total - ceil(BYTES_TO_MEGABYTES(w->inuse_cache));
m->current_max_worker->disk = w->resources->disk.total - BYTES_TO_MEGABYTES(w->inuse_cache);
}

struct set *workers = hash_table_lookup(m->file_worker_table, cachename);
Expand Down
4 changes: 2 additions & 2 deletions taskvine/src/manager/vine_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -2881,7 +2881,7 @@ static void count_worker_resources(struct vine_manager *q, struct vine_worker_in
w->resources->gpus.inuse += box->gpus;
}

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

static void update_max_worker(struct vine_manager *q, struct vine_worker_info *w)
Expand Down Expand Up @@ -5995,7 +5995,7 @@ static void aggregate_workers_resources(
}

// vine_stats wants MB
*inuse_cache = (int64_t)ceil(BYTES_TO_MEGABYTES(*inuse_cache));
*inuse_cache = (int64_t)BYTES_TO_MEGABYTES(*inuse_cache);
}

/* This simple wrapper function allows us to hide the debug.h interface from the end user. */
Expand Down