perf(prefetch): increase cache depth to 5 tracks, 2 concurrent

- V2_PREFETCH_COUNT: 2 -> 5 (cache ~2 min ahead)
- V2_MAX_CONCURRENT_PREFETCH: 1 -> 2 (overlap downloads)
- V2_PREFETCH_LOOKAHEAD: 10 -> 15 (find more Qobuz tracks)

Combined with parallel CMAF segments from previous commit,
this keeps the cache well ahead of playback. The sliding
window re-triggers on every track play, so the 5-track
buffer advances continuously through the queue.

cc
This commit is contained in:
vicrodh committed 2026-04-08 10:27:19 -06:00
1 parent 438cc18851
commit b6035cb3ad
1 file changed
+12 -6
+12 -6
View File
@@ -2258,14 +2258,20 @@ pub async fn v2_start_system_browser_oauth(
// ==================== Prefetch (V2) ====================
/// Number of Qobuz tracks to prefetch (not total tracks, just Qobuz)
const V2_PREFETCH_COUNT: usize = 2;
/// Number of Qobuz tracks to prefetch (not total tracks, just Qobuz).
/// Higher values keep more upcoming tracks in cache for instant playback.
/// CMAF segment downloads are ~24s per Hi-Res track, so 5 tracks means
/// the cache stays ~2 minutes ahead of playback.
const V2_PREFETCH_COUNT: usize = 5;
/// How far ahead to look for tracks to prefetch (to handle mixed playlists)
const V2_PREFETCH_LOOKAHEAD: usize = 10;
/// How far ahead to look for tracks to prefetch (to handle mixed playlists
/// with local/offline tracks interspersed with Qobuz tracks)
const V2_PREFETCH_LOOKAHEAD: usize = 15;
/// Maximum concurrent prefetch downloads
const V2_MAX_CONCURRENT_PREFETCH: usize = 1;
/// Maximum concurrent prefetch downloads (track-level, not segment-level).
/// 2 tracks downloading simultaneously keeps the cache filling while
/// one download is in its cooldown/decryption phase.
const V2_MAX_CONCURRENT_PREFETCH: usize = 2;
lazy_static::lazy_static! {
/// Semaphore to limit concurrent prefetch operations