ipfs / helia-verified-fetch

A fetch-like API for obtaining verified & trustless IPFS CIDs on the web
https://npmjs.com/package/@helia/verified-fetch
Other
11 stars 1 forks source link

Video streaming performance #52

Open achingbrain opened 2 months ago

achingbrain commented 2 months ago

Trying to load the Big Buck Bunny CID via the http gateway takes about 15 seconds to start playing for me. I've managed to get it down to 5-10 seconds with some bitswap optimisations but that's still a really long time.

What's happening is the DAG is wide so Helia gets loads of CID requests in quick succession and it takes time to resolve them. This is great for fast file transfer but terrible for video streaming where we just want the first block as fast as possible.

Setting blockReadConcurrency to 1 (e.g. read one block at a time instead of a whole DAG layer at a time) when .cating the file lowers playback start time to under a second.

To do this more properly we should probably sniff the content type of a file by reading the first block, then set the block read concurrency accordingly (high if it's a file, low if it's a video or image (for progressive rendering?)).

This will be easier with #42 in.

SgtPooki commented 2 months ago

I love the idea of progressive enhancement for how we do dag traversal