mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-04 11:43:57 +08:00
perf(usage): coalesce session-sync notifications and serialize sync execution
Replace per-insert usage notifications with a single notification per sync pass, guard all sync entry points (startup backfill, 60s loop, manual sync) behind a process-wide single-flight tokio mutex, and move blocking file/DB work onto spawn_blocking with MissedTickBehavior::Skip. Extend SessionSyncResult with deferredFiles/suspectedDuplicates observability fields (saturating aggregation) and add a test seam that counts notifications even without an injected AppHandle.
This commit is contained in:
@@ -307,6 +307,8 @@ pub fn sync_codex_usage(db: &Database) -> Result<SessionSyncResult, AppError> {
|
||||
skipped: 0,
|
||||
files_scanned: files.len() as u32,
|
||||
errors: vec![],
|
||||
suspected_duplicates: 0,
|
||||
deferred_files: 0,
|
||||
};
|
||||
|
||||
if files.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user