@@ -864,9 +864,9 @@ PDC_region_cache_clock_cycle(void *ptr)
864
864
pdc_obj_cache * obj_cache , * obj_cache_iter ;
865
865
struct timeval current_time ;
866
866
struct timeval finish_time ;
867
- int nflush = 0 ;
868
- double flush_frequency_s = PDC_CACHE_FLUSH_TIME_INT , elapsed_time = 0.0 ;
869
- int server_rank = 0 ;
867
+ int nflush = 0 ;
868
+ int flush_frequency_s = PDC_CACHE_FLUSH_TIME_INT , elapsed_time = 0.0 ;
869
+ int server_rank = 0 ;
870
870
871
871
char * p = getenv ("PDC_SERVER_CACHE_FLUSH_FREQUENCY_S" );
872
872
if (p != NULL )
@@ -876,30 +876,15 @@ PDC_region_cache_clock_cycle(void *ptr)
876
876
obj_cache_iter = NULL ;
877
877
}
878
878
while (1 ) {
879
- nflush = 0 ;
880
- usleep (1000 );
881
879
pthread_mutex_lock (& pdc_cache_mutex );
882
880
if (!pdc_recycle_close_flag ) {
883
881
pthread_mutex_lock (& pdc_obj_cache_list_mutex );
884
882
gettimeofday (& current_time , NULL );
885
883
obj_cache_iter = obj_cache_list ;
886
- nflush = 0 ;
884
+ nflush = 0 ;
887
885
while (obj_cache_iter != NULL ) {
888
886
obj_cache = obj_cache_iter ;
889
- // flush every *flush_frequency_s seconds
890
- if (obj_cache -> timestamp .tv_sec > 0 )
891
- elapsed_time = current_time .tv_sec - obj_cache_list -> timestamp .tv_sec ;
892
- if (elapsed_time >= flush_frequency_s ) {
893
- /* char tmbuf[64]; */
894
- /* strftime(tmbuf, sizeof tmbuf, "%Y-%m-%d %H:%M:%S",
895
- * localtime(&obj_cache->timestamp.tv_sec)); */
896
- /* fprintf(stderr, "Previous %s\n", tmbuf); */
897
- /* strftime(tmbuf, sizeof tmbuf, "%Y-%m-%d %H:%M:%S", localtime(¤t_time.tv_sec)); */
898
- /* fprintf(stderr, "Current %s\n", tmbuf); */
899
- nflush += PDC_region_cache_flush_by_pointer (obj_cache -> obj_id , obj_cache );
900
- // Update latest flush time
901
- gettimeofday (& obj_cache_list -> timestamp , NULL );
902
- }
887
+ nflush += PDC_region_cache_flush_by_pointer (obj_cache -> obj_id , obj_cache );
903
888
obj_cache_iter = obj_cache_iter -> next ;
904
889
}
905
890
if (nflush > 0 ) {
@@ -913,13 +898,18 @@ PDC_region_cache_clock_cycle(void *ptr)
913
898
"==PDC_SERVER[%d]: %s, flushed %d regions to storage (full/every %.0fs), took %.4fs\n" ,
914
899
server_rank , __func__ , nflush , flush_frequency_s , elapsed_time );
915
900
}
901
+ else
902
+ fprintf (stderr , "==PDC_SERVER[%d]: %s, no cached data flushed\n" , server_rank , __func__ );
903
+
916
904
pthread_mutex_unlock (& pdc_obj_cache_list_mutex );
917
905
}
918
906
else {
919
907
pthread_mutex_unlock (& pdc_cache_mutex );
920
908
break ;
921
909
}
910
+
922
911
pthread_mutex_unlock (& pdc_cache_mutex );
912
+ sleep (flush_frequency_s );
923
913
}
924
914
return 0 ;
925
915
}
0 commit comments