From 9db1e5ca6b4f95e14fba5eed144a0f33a9b5d018 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Mon, 23 Feb 2026 05:24:33 -0600 Subject: [PATCH] perf(cache): increase L1 to 400MB and L2 to 800MB L1 (memory): 300MB -> 400MB (+100MB) L2 (disk): 500MB -> 800MB (+300MB) --- crates/qbz-cache/src/audio_cache.rs | 2 +- crates/qbz-cache/src/lib.rs | 12 ++++++------ src-tauri/src/cache/mod.rs | 4 ++-- src-tauri/src/lib.rs | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/qbz-cache/src/audio_cache.rs b/crates/qbz-cache/src/audio_cache.rs index 32b81fa60..bb09b4bf5 100644 --- a/crates/qbz-cache/src/audio_cache.rs +++ b/crates/qbz-cache/src/audio_cache.rs @@ -43,7 +43,7 @@ pub struct AudioCache { impl Default for AudioCache { fn default() -> Self { - Self::new(300 * 1024 * 1024) // 300MB for ~3-4 Hi-Res tracks + Self::new(400 * 1024 * 1024) // 400MB for ~4-5 Hi-Res tracks } } diff --git a/crates/qbz-cache/src/lib.rs b/crates/qbz-cache/src/lib.rs index e61897f99..f5653c71e 100644 --- a/crates/qbz-cache/src/lib.rs +++ b/crates/qbz-cache/src/lib.rs @@ -1,8 +1,8 @@ //! QBZ Cache - Audio caching system //! //! Provides two-level caching for audio data: -//! - **L1 (Memory)**: In-memory LRU cache (~300MB, fast access) -//! - **L2 (Disk)**: Disk-based playback cache (~500MB, persistent) +//! - **L1 (Memory)**: In-memory LRU cache (~400MB, fast access) +//! - **L2 (Disk)**: Disk-based playback cache (~800MB, persistent) //! //! ## Architecture //! @@ -15,7 +15,7 @@ //! ┌─────────────────────────────────────────────────────────┐ //! │ L1 Memory Cache (AudioCache) │ //! │ - Fast HashMap + LRU tracking │ -//! │ - ~300MB limit (3-4 Hi-Res tracks) │ +//! │ - ~400MB limit (3-4 Hi-Res tracks) │ //! │ - Evicted tracks spill to L2 │ //! └─────────────────────────────────────────────────────────┘ //! │ miss/evict @@ -23,7 +23,7 @@ //! ┌─────────────────────────────────────────────────────────┐ //! │ L2 Disk Cache (PlaybackCache) │ //! │ - File-based storage │ -//! │ - ~500MB limit │ +//! │ - ~800MB limit │ //! │ - LRU eviction by access time │ //! └─────────────────────────────────────────────────────────┘ //! │ miss @@ -38,11 +38,11 @@ //! use std::sync::Arc; //! //! // Create L2 disk cache -//! let playback_cache = Arc::new(PlaybackCache::new(500 * 1024 * 1024).unwrap()); +//! let playback_cache = Arc::new(PlaybackCache::new(800 * 1024 * 1024).unwrap()); //! //! // Create L1 memory cache with L2 spillover //! let audio_cache = AudioCache::with_playback_cache( -//! 300 * 1024 * 1024, +//! 400 * 1024 * 1024, //! playback_cache.clone() //! ); //! diff --git a/src-tauri/src/cache/mod.rs b/src-tauri/src/cache/mod.rs index 344307f21..b6d8c3898 100644 --- a/src-tauri/src/cache/mod.rs +++ b/src-tauri/src/cache/mod.rs @@ -3,8 +3,8 @@ //! Re-exports from qbz-cache crate for backwards compatibility. //! //! Provides two-level caching for audio data: -//! - L1: In-memory LRU cache (fast, limited to ~300MB) -//! - L2: Disk-based playback cache (slower, larger ~500MB) +//! - L1: In-memory LRU cache (fast, limited to ~400MB) +//! - L2: Disk-based playback cache (slower, larger ~800MB) //! //! Flow: //! 1. When a track is evicted from memory, it's saved to disk cache diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 35e47d2fc..4674abd2e 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -93,8 +93,8 @@ impl AppState { device_name: Option, audio_settings: config::audio_settings::AudioSettings, ) -> Self { - // Create playback cache (L2 - disk, 500MB) - let playback_cache = match PlaybackCache::new(500 * 1024 * 1024) { + // Create playback cache (L2 - disk, 800MB) + let playback_cache = match PlaybackCache::new(800 * 1024 * 1024) { Ok(cache) => Some(Arc::new(cache)), Err(e) => { log::warn!( @@ -105,9 +105,9 @@ impl AppState { } }; - // Create audio cache (L1 - memory, 300MB) with optional disk spillover + // Create audio cache (L1 - memory, 400MB) with optional disk spillover let audio_cache = if let Some(pc) = playback_cache { - Arc::new(AudioCache::with_playback_cache(300 * 1024 * 1024, pc)) + Arc::new(AudioCache::with_playback_cache(400 * 1024 * 1024, pc)) } else { Arc::new(AudioCache::default()) };