-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ipfs.cat calls https://node{0..3}.preload.ipfs.io/api/v0/refs?r=true&arg=<hash> on every cat #3307
Comments
Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
Finally, remember to use https://discuss.ipfs.io if you just need general support. |
We 'preload' most CIDs we interact with on the network. In some cases this can mean preloading the same CID over and over again which is not necessary. This PR adds a LRU cache to the preloader with a default size of 1000. The cache is used to avoid re-preloading the same CID over and over again until it drops out of the cache. We use a cache that will evict CIDs over time to have some sort of upper bound on memory usage. Fixes #3307
We 'preload' most CIDs we interact with on the network. In some cases this can mean preloading the same CID over and over again which is not necessary. This PR adds a LRU cache to the preloader with a default size of 1000. The cache is used to avoid re-preloading the same CID over and over again until it drops out of the cache. We use a cache that will evict CIDs over time to have some sort of upper bound on memory usage. Fixes #3307
What's happening here is that Preloading involves hitting the The In practice here the DAG behind The long term fix for this is to make js-IPFS respond to DHT queries and be dialable from the outside, even in the browser, then preloading would not be necessary, though sadly this is a non-trivial undertaking. I've opened #3363 as a short-term fix which caches preloaded CIDs so this should only make one request to the remote |
We 'preload' most CIDs we interact with on the network. In some cases this can mean preloading the same CID over and over again which is not necessary. This PR adds a LRU cache to the preloader with a default size of 1000. The cache is used to avoid re-preloading the same CID over and over again until it drops out of the cache. We use a cache that will evict CIDs over time to have some sort of upper bound on memory usage. Fixes #3307 Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
Platform:
Verified in Firefox 81 and Chrome 85 on Windows, Linux, and Macos
Subsystem:
Unknown
Severity:
Medium
Description:
If there are many repeat calls of
ipfs.cat
on subpaths of a IPFS hash, then each cat will call refs on the root of the hash. The calls are identical, and they don't seem to end up the browser's indexdb, or at least they aren't referenced there again.On large trees, you could end up downloading many gigabytes of the same refs exact refs data.
Steps to reproduce the error:
I discovered this while sending over improvements to moshisushi/hlsjs-ipfs-loader
If you look at the network requests made on https://charade.fu.io you will see hundreds of requests to the following 4 URLS.
There are 1360 parts times 5 different bit rates, and each part cat also triggers ipfs-js to call that refs api for the entire tree, not just for that part. The refs here are 2.5MB. As a result the browser is downloading more than 3.5GB of the same 2.5MB from the preload servers.
The movie Charade (1963) is in the Public Domain, I'm using it as a much longer Big Buck Bunny to enhance the issue. There is no copyright infringement there.
The text was updated successfully, but these errors were encountered: