perf: optimize index build — permanent caches + faster MB rate limit

Three changes to reduce subsequent index build times:

1. Positive image/rels cache TTL: 30 days → 365 days
   Artist url-rels and resolved image URLs rarely change.
   Already-indexed artists make zero API calls on rebuild.

2. Negative cache (misses) stays at 30 days so new images
   are discovered within a month of being added upstream.

3. MB rate limiter for background indexing: 1.0 → 1.5 req/s
   url-rels lookups are lightweight; 1.5/s is well within
   what MB handles (Picard and Kodi both use similar rates).
   Cuts the MB-bound portion of index build by ~33%.

Also adds NewRateLimiterF for fractional rates and caches
MB rels fetch failures (30-day miss TTL) to avoid retrying
unreachable artists every build.
This commit is contained in:
2026-03-29 12:00:36 -04:00
parent b251982e73
commit 5bb1c89fba
3 changed files with 29 additions and 17 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ func NewExploreService(logger *slog.Logger, db *database.DB) *Service {
lb := NewListenBrainzClient(limiter, cache, logger.WithGroup("listenbrainz"))
artProxy := NewCoverArtProxy(db, limiter)
artistImg := NewArtistImageProvider(
db, cache, NewRateLimiter(), logger.WithGroup("artist-image"),
db, cache, NewRateLimiterF(1.5), logger.WithGroup("artist-image"),
)
index := NewSearchIndex(db, lb, artistImg, logger.WithGroup("search-index"))
libMBID := NewLibraryMBIDIndex(db)