High-performance implementation of plcbundle written in Rust

perf(manager): measure and report bundle file write time

Add timing measurement for bundle file write operations and include it in the performance metrics. Also display shortened hash in sync logs for better readability.

+11 -4
+5
src/manager.rs
··· 1726 1726 std::time::Duration, 1727 1727 std::time::Duration, 1728 1728 std::time::Duration, 1729 + std::time::Duration, 1729 1730 bool, 1730 1731 )> { 1731 1732 use anyhow::Context; ··· 1943 1944 let compressed_frames_clone = compressed_frames.clone(); 1944 1945 1945 1946 // Write file first (metadata frame doesn't contain compressed_hash, so we can write it) 1947 + let file_write_start = Instant::now(); 1946 1948 tokio::task::spawn_blocking({ 1947 1949 let bundle_path_clone = bundle_path_clone.clone(); 1948 1950 let bundle_metadata_frame_clone = bundle_metadata_frame_clone.clone(); ··· 1985 1987 }) 1986 1988 .await 1987 1989 .context("Bundle file write task failed")??; 1990 + 1991 + let file_write_time = file_write_start.elapsed(); 1988 1992 1989 1993 // Now calculate compressed_hash from the entire file (as verification does) 1990 1994 let compressed_hash = tokio::task::spawn_blocking({ ··· 2080 2084 Ok(( 2081 2085 serialize_time, 2082 2086 compress_time, 2087 + file_write_time, 2083 2088 hash_time, 2084 2089 did_index_time, 2085 2090 index_write_time,
+6 -4
src/sync.rs
··· 279 279 format!("{:.0}KB", size_kb) 280 280 }; 281 281 282 + let short_hash = &result.hash[..std::cmp::min(7, result.hash.len())]; 282 283 eprintln!( 283 284 "[INFO] → Bundle {:06} | {} | {} dids | {} | fetch: {:.2}s ({} reqs, {:.1}s wait) | save: {}ms | index: {}ms | {}", 284 285 result.bundle_num, 285 - result.hash, 286 + short_hash, 286 287 result.unique_dids, 287 288 size_str, 288 289 fetch_secs, ··· 738 739 739 740 // Save bundle 740 741 let ( 741 - _serialize_time, 742 - _compress_time, 742 + serialize_time, 743 + compress_time, 744 + save_time, 743 745 _hash_time, 744 746 _did_index_time, 745 747 index_ms, ··· 785 787 mempool_count: remaining_ops.len(), 786 788 total_duration_ms: total_duration_ms as u64, 787 789 fetch_duration_ms: fetch_duration_ms as u64, 788 - bundle_save_ms: 0, // Included in index_ms/total for now or need to separate 790 + bundle_save_ms: (serialize_time + compress_time + save_time).as_millis() as u64, 789 791 index_ms: index_ms.as_millis() as u64, 790 792 fetch_requests: fetch_stats.fetch_num, 791 793 hash: self