-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: file upload without buffering #1534
Conversation
per @olizilla import / add button on the files view listened for @rafaelramalho19 any idea what am I doing wrong in my pull request, that causes the import view not to show until upload is fully complete ? |
Edit: Turns out I was testing with a version that did not include my changes and timing looks significantly better ~19secs, although still not great. |
Contrast with adding via CLI is massive extra
I do not exactly know what is the problem here, but clearly this needs investigation. |
Checked also with curl which takes around ~3secs, which is kind of throughput I would like to see with webUI.
|
Wrote a simple node server that just calculates number of bytes received and writes back chunks back Which leads to upload times between 10s to 12s With that 19s to do actual IPFS add doesn't seem all that bad. I also see from server output that browser is streaming data in chunks, that being said it is still unclear why it is taking this long. |
|
I did bit more investigation with my node server and it appears that Chrome uploads 2gigs file in 108237 chunks (~19kb per chunk) This leads me believe that difference in chunking could lead to observed throughput difference. I am unaware if there is any way to control chunking of XHR upload, so I'm out of ideas. |
Relevant pointer to #1495 from @rafaelramalho19 |
Blocked on ipfs/js-ipfs-utils#54 |
Never mind. Turns out native form data patch has not made it to With the following change things work as expected (matching previously reported numbers) diff --git a/package.json b/package.json
index d87f56c..e129beb 100644
--- a/package.json
+++ b/package.json
@@ -47,7 +47,7 @@
"ip": "^1.1.5",
"ipfs-css": "^1.2.0",
"ipfs-geoip": "^4.1.0",
- "ipfs-http-client": "^45.0.0",
+ "ipfs-http-client": "next",
"ipfs-provider": "^1.0.0",
"ipld-explorer-components": "1.6.0",
"is-binary": "^0.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
@rafaelramalho19 mind takign a look and if ok merging this?
CI did not execute because this is an old PR Irakli did from a fork, but I've run E2E tests locally and confirmed it is all green.
It would be nice to add server timing API into IPFS HTTP API.
Ack, created ipfs/in-web-browsers#167 to discuss that further
// Just estimate download size to be around 10% of upload size. | ||
const downloadSize = uploadSize * 10 / 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: what does "download" mean in this context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It refers to the response body estimate. Which would translate to progressbar speeding up towards the end.
Looks good! I can finally upload 10gb files on both MacOS and Windows 🙏 After this gets unblocked feel free to merge 😄 |
Can you please elaborate what you mean ? We can land this now and once new ipfs-http-client is published things would actually stop buffering. Alternatively we could wait for ipfs-http-client to be published first and then bump dependency version. However since it's going to minor version update I don't think it's worth waiting. |
@Gozala was new ipfs-http-client published with the changes we were waitig for? |
Version 2
This pull request takes advantage of following changes
Please note that ipfs/js-ipfs#3184 is coming in
ipfs-http-client@45.0.1
and to observe the fix you'd need to modify dependency inpackage.json
as follows. I do not think we need to block this on release since minor version bump will be picked up automatically.Also note that while pull request introducing upload / download progress events is still pending, we don't need to block this because:
Therefor we can land this and once ipfs-http-client starts emitting upload / download progress events they will just start emitting
FILES_WRITE_UPDATED
actions.Everything below is no longer reflects current state of the pull request, but keeping it around for history.
Version 1 (Retaining for historical)
This pull request explores a ways to upload files without unnecessary buffering. High level overview of changes below:
ipfs.add
has a complex API that can takeAsyncIterable
of files withAsyncIterable
contents. Optimize such API has several issues:For above reasons this draft pull in experimental
ipfs-lite-http-client
providing much more simplifiedipfs.add
functionality that only accepts inputs optimal for web. It is not here to stay, but here to make a case thatipfs.add
API is inadequate for use cases like this.filesToStreams
function used to turn DOMFile
into structure withcontent
s of it represented as a stream. Which in turn than had to be buffered by anipfs-http-client
. This function is gone now andFile
instances are used instead. **However I'm not confident there is no code paths that assume old file like structures instead ofFile
instances.I can successfully upload files with multiple gigs in size, it does take quite a bit time and I see no progress reports.
ipfs-lite-http-client
does report progress updates and I can see those being called however I can't seem to figure out where dispatch ofFILES_WRITE_UPDATED
leads to. I suspect handler of that action doesn't get what it expects and that is why progress doesn't get reported till the very end. Help here would be welcome.might fix #1529