mirror of
https://github.com/narrrl/proton-stream.git
synced 2026-11-04 16:57:00 +01:00
perf(stream,core): take the disk cache off the read path, warm file edges, report crawl progress
A block the player waits for no longer waits on its disk-cache write and two fsyncs; the put runs in a spawned task and only the block itself is synced before the rename. Opening a stream can fetch the first and last block together, where MKV cues and the MP4 moov live. Downloads open a copying stream that reads the disk cache but never fills it. crawl_reporting reports the running file count after each listing.
This commit is contained in:
1 parent
6f28a9c377
commit
8f78f5c1b1
4 files changed
+195
-8
No files matched your search
@@ -155,6 +155,24 @@ impl StreamSource {
|
||||
.await
|
||||
}
|
||||
|
||||
/// Open a file to copy it out whole, rather than to play it.
|
||||
///
|
||||
/// Not the playback stream, and not shared with it: its blocks are read
|
||||
/// once and written to a file, so caching them in memory only evicts the
|
||||
/// blocks a viewer is about to need, and caching them on disk stores every
|
||||
/// byte twice while pushing out what was just watched. It does still read
|
||||
/// the disk cache — an episode watched and then downloaded is not fetched
|
||||
/// again.
|
||||
pub async fn open_for_copy(&self, share_id: &str, uid: &NodeUid) -> Result<VideoStream> {
|
||||
let blocks = self.inner.opener.open(share_id, uid).await?;
|
||||
Ok(VideoStream::copying(
|
||||
uid.clone(),
|
||||
blocks,
|
||||
Arc::new(BlockRing::new(0)),
|
||||
self.inner.disk.clone(),
|
||||
))
|
||||
}
|
||||
|
||||
/// Drop a stream and everything cached for it in memory.
|
||||
///
|
||||
/// The disk cache is deliberately untouched: it exists precisely so the next
|
||||
|
||||
Reference in new issue
Block a user