Performance: faster scans, thumbnails, library JSON, and codegen
Four changes that compound — most users will notice these on first launch of a large library. ## Release profile - opt-level: 2 → 3 (more inlining + vectorization, ~5-15% on hot paths) - lto = "thin" (cross-crate inlining; thin avoids the rust-lld + bundled sqlite link breakage that full LTO previously caused, which is what the !lto note was about) - codegen-units = 1 (whole-crate inlining, ~5% runtime, +30s build) - strip = "debuginfo" (drops ~30 MB from the binary) ## Thumbnail decode pool The single decoder thread was the bottleneck on grid fill for libraries with hundreds of channels. Replace with a worker pool sized at clamp(2, cores/2, 8). Workers share the request channel behind a Mutex; lock contention is negligible because each worker spends ~all its time in image::open + resize. ## info.json parse cache Library scans re-parse every video's info.json sidecar on every rescan — serde_json::from_str is the dominant cost on a warm-filesystem scan (file reads themselves are OS-cached). Add a `info_cache` SQLite table keyed by (path, mtime); enrich_with_cache hits it first and only parses on miss. mtime-keyed invalidation means yt-dlp re-writing an info.json auto-invalidates without explicit eviction. Each scan worker checks out its own r2d2 connection so lookups don't serialize. Database is now Clone (the inner Pool is Arc, so cloning is cheap) so we can hand handles to parallel workers. ## /api/library body cache The ETag short-circuit catches clients with a matching cached version; this catches clients without one (curl, freshly-opened tabs, mobile WebViews that don't store ETags reliably). When the version matches the cached entry's, we hand back the previously-serialized bytes without re-walking the channel tree or re-running serde_json::to_string. A post-build version check prevents poisoning the cache with stale bytes when the library changes during serialization. 74 tests pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
c1bd88d800
commit
0fe6063f6b
6 changed files with 269 additions and 49 deletions
6
PKGBUILD
6
PKGBUILD
|
|
@ -18,7 +18,11 @@ optdepends=(
|
|||
'libnotify: desktop notifications when downloads finish'
|
||||
)
|
||||
makedepends=('rust' 'cargo')
|
||||
options=('!lto') # rusqlite bundled sqlite cannot be LTO-linked with rust-lld
|
||||
# Disable makepkg's environment-level LTO so we don't double up with the
|
||||
# Cargo.toml profile (which sets lto = "thin"). Full LTO via rust-lld
|
||||
# previously broke the rusqlite bundled-sqlite link; thin LTO in Cargo
|
||||
# does the cross-crate inlining we actually want.
|
||||
options=('!lto')
|
||||
source=("git+https://codeberg.org/anassaeneroi/yt-offline.git#branch=main")
|
||||
sha256sums=('SKIP')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue