musikr: batch cache writes to reduce fsync overhead on cold scan (#1365)

Replace per-song Room inserts with chunked bulk inserts (500 songs per
transaction). Reduces ~3000 individual fsync calls to ~6 on a full
cold scan, cutting write time from seconds to milliseconds on typical
eMMC/UFS storage. Adds writeAll() to MutableCache with a default
fallback for external implementors, and unit tests for the chunking
behaviour.
This commit is contained in:
shapeshed
2026-08-29 14:19:10 -06:00
committed by GitHub
parent 5bd1efe61d
commit 4546cda499
6 changed files with 183 additions and 33 deletions
@@ -35,6 +35,10 @@ class WriteOnlyMutableCache(private val inner: MutableCache) : MutableCache {
inner.write(cachedFile)
}
override suspend fun writeAll(cachedFiles: List<CachedFile>) {
inner.writeAll(cachedFiles)
}
override suspend fun cleanup(excluding: List<CachedFile>) {
inner.cleanup(excluding)
}