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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user