@@ -553,7 +553,6 @@ pub struct WorkerTask {
553553fn start_store_writer_thread (
554554 logger : slog:: Logger ,
555555 mut store : store:: StoreWriter ,
556- _stats : Arc < Mutex < statistics:: Statistics > > ,
557556 store_size_limit : Option < u64 > ,
558557 retention : Option < Duration > ,
559558 writer_buffer_size : usize ,
@@ -563,6 +562,7 @@ fn start_store_writer_thread(
563562 . name ( "store_writer" . to_owned ( ) )
564563 . spawn ( move || {
565564 loop {
565+ let loop_start_time = Instant :: now ( ) ;
566566 match recv_task. recv ( ) {
567567 Ok ( write_task) => {
568568 match store. put ( write_task. post_collect_sys_time , & write_task. data ) {
@@ -573,11 +573,18 @@ fn start_store_writer_thread(
573573 store_size_limit,
574574 /* retention */ None ,
575575 )
576- . expect ( "cleanup_store failed" )
576+ . expect ( "cleanup_store failed" ) ;
577577 }
578578 Ok ( /* new shard */ false ) => { }
579- Err ( e) => error ! ( logger, "{:#}" , e) ,
579+ Err ( e) => {
580+ error ! ( logger, "{:#}" , e) ;
581+ // no need to report/cleanup
582+ continue ;
583+ }
580584 }
585+ statistics:: report_writer_time_ms (
586+ Instant :: now ( ) . duration_since ( loop_start_time) ,
587+ ) ;
581588 }
582589 Err ( _) => {
583590 warn ! (
@@ -1095,12 +1102,11 @@ fn record(
10951102 store:: Format :: Cbor ,
10961103 ) ?;
10971104
1098- let shared_stats = Arc :: new ( Mutex :: new ( statistics:: Statistics :: new ( init) ) ) ;
1105+ let mut stats = statistics:: Statistics :: new ( init) ;
10991106
11001107 let ( writer_thread, send_task) = start_store_writer_thread (
11011108 logger. clone ( ) ,
11021109 store,
1103- Arc :: clone ( & shared_stats) ,
11041110 store_size_limit,
11051111 retention,
11061112 writer_buffer_size,
@@ -1153,17 +1159,13 @@ fn record(
11531159 collection_skew. as_millis( ) ,
11541160 skew_detection_threshold. as_millis( )
11551161 ) ;
1156- shared_stats
1157- . lock ( )
1158- . expect ( "error acquired stats lock" )
1159- . report_collection_skew ( ) ;
1162+ statistics:: report_collection_skew ( ) ;
11601163 }
11611164
11621165 match collected_sample {
11631166 Ok ( s) => {
11641167 if below_config. enable_gpu_stats {
1165- let mut lock = shared_stats. lock ( ) . expect ( "error acquiring stats lock" ) ;
1166- lock. report_nr_accelerators ( & s) ;
1168+ stats. report_nr_accelerators ( & s) ;
11671169 }
11681170 send_task
11691171 . send ( WorkerTask {
@@ -1182,12 +1184,11 @@ fn record(
11821184 }
11831185 } ;
11841186
1185- {
1186- let mut lock = shared_stats. lock ( ) . expect ( "error acquired stats lock" ) ;
1187- lock. report_store_size ( below_config. store_dir . as_path ( ) ) ;
1188- }
1187+ stats. report_store_size ( below_config. store_dir . as_path ( ) ) ;
11891188
11901189 let collect_duration = Instant :: now ( ) . duration_since ( collect_instant) ;
1190+ statistics:: report_collection_time_ms ( collect_duration) ;
1191+
11911192 // Sleep for at least 1s to avoid sample collision
11921193 let sleep_duration = if interval > collect_duration {
11931194 std:: cmp:: max ( Duration :: from_secs ( 1 ) , interval - collect_duration)
0 commit comments