mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 06:25:41 +00:00
fix: prune stale analysis queues and cap loudness backfill window (#480)
* fix(analysis): prune stale backfill jobs and limit prefetch window Drop pending backfill and cpu-seed jobs that are no longer in the active playback queue, and add debug counters for pruned work. Limit loudness backfill scheduling to the current track plus the next five tracks to prevent runaway queue growth in dev sessions. * chore(analysis): remove unused loudness prefetch parameter Drop the now-unused incoming-tracks parameter from the loudness prefetch helper and update internal call sites to match the current queue-window scheduling logic. * docs(changelog): document analysis queue control fix (#480) Add a short 1.46.0 Fixed entry describing stale backfill pruning, the current+5 loudness backfill window cap, and debug prune counters for diagnostics. * docs(contributors): add cucadmuh entry for PR #480 Logs the analysis-queue prune + loudness backfill window cap in the Settings → System → Contributors list.
This commit is contained in:
+30
-1
@@ -10,7 +10,7 @@ mod lib_commands;
|
||||
#[cfg(target_os = "windows")]
|
||||
mod taskbar_win;
|
||||
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::collections::{HashMap, HashSet, VecDeque};
|
||||
use std::sync::{Arc, Mutex, OnceLock, RwLock};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
@@ -127,6 +127,13 @@ impl AnalysisBackfillQueueState {
|
||||
AnalysisBackfillEnqueueKind::NewBack
|
||||
}
|
||||
}
|
||||
|
||||
fn prune_queued_not_in(&mut self, keep_track_ids: &HashSet<&str>) -> usize {
|
||||
let before = self.deque.len();
|
||||
self.deque
|
||||
.retain(|(track_id, _)| keep_track_ids.contains(track_id.as_str()));
|
||||
before.saturating_sub(self.deque.len())
|
||||
}
|
||||
}
|
||||
|
||||
struct AnalysisBackfillShared {
|
||||
@@ -300,6 +307,27 @@ impl AnalysisCpuSeedQueueState {
|
||||
};
|
||||
(kind, done_rx)
|
||||
}
|
||||
|
||||
fn prune_queued_not_in(&mut self, keep_track_ids: &HashSet<&str>) -> (usize, usize) {
|
||||
let mut kept = VecDeque::with_capacity(self.deque.len());
|
||||
let mut removed_jobs = 0usize;
|
||||
let mut removed_waiters = 0usize;
|
||||
while let Some(job) = self.deque.pop_front() {
|
||||
if keep_track_ids.contains(job.track_id.as_str()) {
|
||||
kept.push_back(job);
|
||||
continue;
|
||||
}
|
||||
removed_jobs += 1;
|
||||
removed_waiters += job.waiters.len();
|
||||
for tx in job.waiters {
|
||||
let _ = tx.send(Err(
|
||||
"cpu-seed pruned: track no longer in playback queue".to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
self.deque = kept;
|
||||
(removed_jobs, removed_waiters)
|
||||
}
|
||||
}
|
||||
|
||||
struct AnalysisCpuSeedShared {
|
||||
@@ -920,6 +948,7 @@ pub fn run() {
|
||||
analysis_delete_loudness_for_track,
|
||||
analysis_delete_all_waveforms,
|
||||
analysis_enqueue_seed_from_url,
|
||||
analysis_prune_pending_to_track_ids,
|
||||
download_track_offline,
|
||||
delete_offline_track,
|
||||
get_offline_cache_size,
|
||||
|
||||
Reference in New Issue
Block a user