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

Fix the server cache issue when cache becomes full and needs flush #113

Merged
merged 2 commits into from
Jul 27, 2023
Merged
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
20 changes: 15 additions & 5 deletions src/server/pdc_server_region/pdc_server_region_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,11 @@ PDC_region_cache_register(uint64_t obj_id, int obj_ndim, const uint64_t *obj_dim
struct pdc_region_info *region_cache_info;
if (obj_ndim != ndim && obj_ndim > 0) {
printf("PDC_region_cache_register reports obj_ndim != ndim, %d != %d\n", obj_ndim, ndim);
return FAIL;
}

pthread_mutex_lock(&pdc_obj_cache_list_mutex);

obj_cache_iter = obj_cache_list;
while (obj_cache_iter != NULL) {
if (obj_cache_iter->obj_id == obj_id) {
Expand Down Expand Up @@ -460,7 +463,15 @@ PDC_region_cache_register(uint64_t obj_id, int obj_ndim, const uint64_t *obj_dim
memcpy(region_cache_info->buf, buf, sizeof(char) * buf_size);
total_cache_size += buf_size;

pthread_mutex_unlock(&pdc_obj_cache_list_mutex);

if (total_cache_size > maximum_cache_size) {
int server_rank = 0;
#ifdef ENABLE_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &server_rank);
#endif
printf("==PDC_SERVER[%d]: server cache full %.1f / %.1f MB, will flush to storage\n", server_rank,
total_cache_size / 1048576.0, maximum_cache_size / 1048576.0);
PDC_region_cache_flush_all();
}

Expand Down Expand Up @@ -571,11 +582,11 @@ PDC_transfer_request_data_write_out(uint64_t obj_id, int obj_ndim, const uint64_
region_cache_iter = region_cache_iter->next;
}
}
pthread_mutex_unlock(&pdc_obj_cache_list_mutex);
if (!flag) {
PDC_region_cache_register(obj_id, obj_ndim, obj_dims, buf, write_size, region_info->offset,
region_info->size, region_info->ndim, unit);
}
pthread_mutex_unlock(&pdc_obj_cache_list_mutex);

// PDC_Server_data_write_out2(obj_id, region_info, buf, unit);
#ifdef PDC_TIMING
Expand Down Expand Up @@ -862,10 +873,9 @@ PDC_region_cache_clock_cycle(void *ptr)
gettimeofday(&finish_time, NULL);
elapsed_time = finish_time.tv_sec - current_time.tv_sec +
(finish_time.tv_usec - current_time.tv_usec) / 1000000.0;
fprintf(
stderr,
"==PDC_SERVER[%d]: flushed %d regions from cache to storage (every %.1fs), took %.4fs\n",
server_rank, nflush, flush_frequency_s, elapsed_time);
fprintf(stderr,
"==PDC_SERVER[%d]: flushed %d regions to storage (full/every %.0fs), took %.4fs\n",
server_rank, nflush, flush_frequency_s, elapsed_time);
}
pthread_mutex_unlock(&pdc_obj_cache_list_mutex);
}
Expand Down
Loading