catacomb/PKGBUILD
Luna 0fe6063f6b 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>
2026-05-27 03:28:40 -07:00

52 lines
1.7 KiB
Bash

# Maintainer: InannaBeloved <anassaeneroi@pm.me>
pkgname=yt-offline
pkgver=0.1.0
pkgrel=1
pkgdesc="Self-hosted archive for YouTube, TikTok, Twitch, Vimeo, Bandcamp, SoundCloud, Odysee and more. Desktop GUI + web UI."
arch=('x86_64' 'aarch64')
url="https://codeberg.org/anassaeneroi/yt-offline"
license=('AGPL-3.0-only')
depends=(
'yt-dlp'
'ffmpeg'
'mpv'
'sqlite'
'libxcb'
'xdg-utils'
)
optdepends=(
'libnotify: desktop notifications when downloads finish'
)
makedepends=('rust' 'cargo')
# 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')
pkgver() {
cd "$pkgname"
# 0.1.0.r12.gabcdef0 — last tag, commits since, short hash
git describe --long --tags --always 2>/dev/null \
| sed 's/^v//; s/\([^-]*-g\)/r\1/; s/-/./g' \
|| printf "0.1.0.r%s.g%s" \
"$(git rev-list --count HEAD)" \
"$(git rev-parse --short HEAD)"
}
build() {
cd "$pkgname"
cargo build --release --frozen
}
package() {
cd "$pkgname"
install -Dm755 target/release/yt-offline "$pkgdir/usr/bin/yt-offline"
install -Dm644 youtube-backup.desktop "$pkgdir/usr/share/applications/yt-offline.desktop"
install -Dm644 icon.png "$pkgdir/usr/share/pixmaps/yt-offline.png"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
}