Repository navigation
Performance
Kopuz is built to feel snappy even with large libraries. Here's what we do under the hood:
-
Skip what's already indexed - the scanner keeps a
HashSetof every path it's already seen, so rescans only process new files. If you have 10,000 tracks, and then add 5 new ones, Kopuz will not re-read the other 9995. This makes a huge difference, especially on HDDs. -
Parallel startup loading - on launch, library, config, playlists, and favorites all load in parallel with
tokio::join!. Before this change, everything loaded sequentially and you'd stare at a blank window for a bit. Now it's near-instant. -
Album art caching - cover images get extracted once and saved to disk (
~/.cache/kopuz/covers/on Linux,~/Library/Caches/on macOS). We also cache the macOS now-playing artwork object in memory so it doesn't re-decode the image every time the progress bar updates. -
Lazy loading images - album covers in search results, track rows, and genre views all use
loading="lazy"so we're not loading hundreds of images at once when you scroll through a big library. -
Non-blocking I/O - all the heavy stuff (metadata parsing, file scanning, saving library state) runs on
spawn_blockingthreads so the UI never freezes. The main thread stays responsive even during a full library scan. -
Smarter sorting - we use
sort_by_cached_keyinstead of regularsort_by_keyfor library views, which avoids recalculating the sort key (like.to_lowercase()) on every comparison. Small thing perhaps, but it adds up with thousands of tracks. -
HTTP caching for artwork - the custom
artwork://protocol serves images withCache-Control: public, max-age=31536000so the Webview doesn't re-request covers it already has.
Overall, these changes brought the rescan time down significantly and the app feels much more responsive, especially with libraries over 5000 tracks. Memory usage stays reasonable too since we're not holding decoded images in memory longer than needed.