Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

refactor: exported file links #13

Closed
wants to merge 1 commit into from
Closed

Conversation

alanshaw
Copy link
Contributor

@alanshaw alanshaw commented Jan 2, 2019

Previously we used getMany to get ALL of the links for a particular file node before passing them on to the next step in the pipeline.

This PR refactors that to get the blocks individually in parallel, allowing them to be passed on to the next stage in the pipeline as they arrive.

I don't know if this is faster than the previous method. In fact, I can see how it might be slower. However, it does mean that we don't have to wait for ALL linked blocks to arrive before they are passed to the next stage in the pipeline and by doing this it will reduce the time to first byte when using ipfs.cat*Stream which is good from a UX perspective.

A streaming getMany from IPLD would actually be useful here, which could be pushed down to bitswap so that it can make good decisions about what network requests to make.

cc @vmx

Previously we used `getMany` to get **ALL** of the links for a particular file node before passing them on to the next step in the pipeline.

This PR refactors that to get the blocks _individually in parallel_, allowing them to be passed on to the next stage in the pipeline as they arrive.

I don't know if this is faster than the previous method. In fact, I can see how it might be slightly slower. However, it does mean that we don't have to wait for **ALL** linked blocks to arrive before they are passed to the next stage in the pipeline and by doing this it will reduce the time to first byte when using `ipfs.cat*Stream` which is good from a UX perspective.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
@alanshaw
Copy link
Contributor Author

alanshaw commented Jan 2, 2019

This PR was created while I was looking into ipfs/js-ipfs#1706 (comment) - it's worth having a quick read of the discussion there!

@achingbrain
Copy link
Collaborator

ipld.getMany was used to not overwhelm the DHT with requests, when it arrives. See ipfs-inactive/js-ipfs-unixfs-engine#216 for context, and this comment in particular.

A streaming ipld.getMany would be a better solution, and should form part of the discussion around ipld/js-ipld#182 and/or ipld/js-ipld#185

@alanshaw
Copy link
Contributor Author

alanshaw commented Jan 3, 2019

I'm going to close this for now - getMany is the right thing to do here, but it needs to become streaming at some point in the future so we don't have to hold up everything while we wait for the slowest block to arrive.

@alanshaw alanshaw closed this Jan 3, 2019
@ghost ghost removed the in progress label Jan 3, 2019
@achingbrain
Copy link
Collaborator

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants