High-performance implementation of plcbundle written in Rust

refactor(sync): improve code formatting and timing calculation

+16 -10
+1 -1
src/format.rs
··· 315 315 assert_eq!(format_bytes_per_sec(1536.0), "1.5 KB/sec"); 316 316 assert_eq!(format_bytes_per_sec(1024.0 * 1024.0), "1.0 MB/sec"); 317 317 } 318 - } 318 + }
+15 -9
src/sync.rs
··· 539 539 let op: Operation = plc_op.into(); 540 540 541 541 // CRITICAL: Check against previous boundary CIDs 542 - if op.cid.as_ref().is_some_and(|cid| prev_boundary.contains(cid)) { 542 + if op 543 + .cid 544 + .as_ref() 545 + .is_some_and(|cid| prev_boundary.contains(cid)) 546 + { 543 547 batch_boundary_dupes += 1; 544 548 continue; 545 549 } ··· 743 747 compress_time, 744 748 save_time, 745 749 _hash_time, 746 - _did_index_time, 747 - index_ms, 750 + did_index_time, 751 + index_write_time, 748 752 did_index_compacted, 749 753 ) = self 750 754 .manager ··· 757 761 self.manager.add_to_mempool(remaining_ops_vec)?; 758 762 } 759 763 760 - let total_duration = fetch_stats.fetch_duration + index_ms; 764 + let total_duration = fetch_stats.fetch_duration 765 + + serialize_time 766 + + compress_time 767 + + save_time 768 + + did_index_time 769 + + index_write_time; 761 770 let total_duration_ms = total_duration.as_secs_f64() * 1000.0; 762 771 763 772 // Count unique DIDs for stats ··· 788 797 total_duration_ms: total_duration_ms as u64, 789 798 fetch_duration_ms: fetch_duration_ms as u64, 790 799 bundle_save_ms: (serialize_time + compress_time + save_time).as_millis() as u64, 791 - index_ms: index_ms.as_millis() as u64, 800 + index_ms: (did_index_time + index_write_time).as_millis() as u64, 792 801 fetch_requests: fetch_stats.fetch_num, 793 802 hash: self 794 803 .manager ··· 881 890 } 882 891 883 892 pub async fn run_continuous(&self) -> Result<()> { 884 - 885 893 let mut total_synced = 0u32; 886 894 let mut is_initial_sync = true; 887 895 ··· 920 928 .and_then(|v| v.as_u64()) 921 929 .unwrap_or(0); 922 930 923 - let sync_result = self 924 - .sync_next_bundle(self.config.shutdown_rx.clone()) 925 - .await; 931 + let sync_result = self.sync_next_bundle(self.config.shutdown_rx.clone()).await; 926 932 927 933 match sync_result { 928 934 Ok(SyncResult::BundleCreated(result)) => {