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: inconsistent usage of BYTES_TO_MEGABYTES #4082

Closed
JinZhou5042 opened this issue Mar 1, 2025 · 2 comments
Closed

vine: inconsistent usage of BYTES_TO_MEGABYTES #4082

JinZhou5042 opened this issue Mar 1, 2025 · 2 comments
Assignees
Labels

Comments

@JinZhou5042
Copy link
Member

JinZhou5042 commented Mar 1, 2025

There are some places where BYTES_TO_MEGABYTES is used directly, while others apply ceil().

I’m wondering if these different usages could lead to inconsistencies in calculations, potentially accumulating errors over several hours as the system processes millions of replicas.

Code using ceil(BYTES_TO_MEGABYTES)

// 1. vine_file_replica_table_insert()
double prev_available = w->resources->disk.total - ceil(BYTES_TO_MEGABYTES(w->inuse_cache + replica->size));
// 2. vine_file_replica_table_insert()
m->current_max_worker->disk = w->resources->disk.total - ceil(BYTES_TO_MEGABYTES(w->inuse_cache));
// 3. count_worker_resources()
w->resources->disk.inuse += ceil(BYTES_TO_MEGABYTES(w->inuse_cache));
// 4. aggregate_workers_resources()
*inuse_cache = (int64_t)ceil(BYTES_TO_MEGABYTES(*inuse_cache));

Code using BYTES_TO_MEGABYTES

// 1. vine_file_replica_table_remove()
double available = w->resources->disk.total - BYTES_TO_MEGABYTES(w->inuse_cache);
// 2. handle_cache_update()
w->resources->disk.inuse += BYTES_TO_MEGABYTES(size);
// 3. vine_manager_choose_resources_for_task()
int64_t available_disk = w->resources->disk.total - BYTES_TO_MEGABYTES(w->inuse_cache);
// 4. update_max_worker()
if (q->current_max_worker->disk < (w->resources->disk.total - BYTES_TO_MEGABYTES(w->inuse_cache))) {
    q->current_max_worker->disk = w->resources->disk.total - BYTES_TO_MEGABYTES(w->inuse_cache);
}
@JinZhou5042 JinZhou5042 self-assigned this Mar 1, 2025
@btovar
Copy link
Member

btovar commented Mar 3, 2025

Good catch! Yes, we should we doing the same everywhere. I'd suggest modifying the macro itself to ensure the same use in each case.

@JinZhou5042
Copy link
Member Author

fixed in #4088

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants