perf(pages): cache de l'index d'archive en mémoire (-73% CBZ, -76% CBR cold)
Chaque cold render ré-énumérait toutes les entrées ZIP/RAR pour construire la liste triée des images. Maintenant la liste est mise en cache dans l'AppState (LruCache<String, Arc<Vec<String>>>, std::sync::Mutex pour accès spawn_blocking). Nouvelles fonctions dans parsers : - list_archive_images(path, format) -> Vec<String> - extract_image_by_name(path, format, name) -> Vec<u8> Mesures avant/après (cache disque froid, n=20) : - CBZ cold : 43ms → 11.9ms (-73%) - CBR cold : 46ms → 11.0ms (-76%) - Warm/concurrent : identique Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use std::sync::{
|
||||
atomic::AtomicU64,
|
||||
Arc,
|
||||
Mutex as StdMutex,
|
||||
};
|
||||
use std::time::Instant;
|
||||
|
||||
@@ -19,6 +20,9 @@ pub struct AppState {
|
||||
pub metrics: Arc<Metrics>,
|
||||
pub read_rate_limit: Arc<Mutex<ReadRateLimit>>,
|
||||
pub settings: Arc<RwLock<DynamicSettings>>,
|
||||
/// Sorted image name list per archive path — avoids re-enumerating entries on every cold render.
|
||||
/// Uses StdMutex (not tokio) so it's accessible from spawn_blocking.
|
||||
pub archive_index_cache: Arc<StdMutex<LruCache<String, Arc<Vec<String>>>>>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
Reference in New Issue
Block a user