Skip to content
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

Maximum transfer speed of 30 MB/s, even on same device? #154

Open
josephrocca opened this issue May 20, 2023 · 7 comments
Open

Maximum transfer speed of 30 MB/s, even on same device? #154

josephrocca opened this issue May 20, 2023 · 7 comments

Comments

@josephrocca
Copy link

Hi, really cool project!

Context:

If I create a dummy 10G file like this:

fallocate -l 10G dummyfile

and then open two browser tabs on the same device, the transfer takes about 5 minutes - i.e. it averages 30 MB/s. This surprised me, because my internet connection has 100MB/s, and I can e.g. download this ~10GB file from Hugging Face in less than 2 mins.

Question:

I'm wondering if this is a fundamental limitation of WebRTC, or if there are potentially very significant performance optimisations which could be made to e.g. get to hundreds of MB/s or several GB/s. I'd have expected at least hundreds of MB/s for two browser tabs on the same device.

@josephrocca
Copy link
Author

josephrocca commented May 20, 2023

Related: https://stackoverflow.com/questions/61280860/do-browser-engines-limit-webrtc-speeds

I've also just tested instant.io (which uses WebTorrent, which uses WebRTC) and I'm not able to get more than 30 MB/s even with multiple seeding peers. Although all my peers were on the same network - not sure whether that could be limiting it.

@josephrocca
Copy link
Author

josephrocca commented May 20, 2023

I've just created a very simple WebRTC DataChannel speed test, and it does indeed look like it won't go higher than 30 MB/s even with unordered, and no retransmission of lost data:

@szimek
Copy link
Owner

szimek commented May 20, 2023

Thanks for looking into it! I don't know if there is a limit, and if yes, what it is.

This app uses a very primitive "protocol", especially that it was written before some new WebRTC features became available. The way it works is the following:

  1. sender reads a 1MB chunk from a file
  2. sender sends this chunk to the recipient
  3. recipient receives the chunk
  4. unless it was the last chunk, the recipient sends a message to request the next one and the whole process is repeated

There are a few optimizations possible:

  • the sender could read the next chunk before it's requested from the recipient, to have it ready by then
  • the sender could use buffering to keep sending data as long as the buffered amount is low enough, instead of sending of waiting for the recipient to acknowledge each chunk
  • the chunk size is 1MB, though it's recommended that the message size be 64KB

I don't know if any of these would actually have a significant impact, though.

@josephrocca
Copy link
Author

I've posted an issue on crbug here: https://bugs.chromium.org/p/chromium/issues/detail?id=1447329 Hopefully a Chromium engineer will chime with some info on the fundamental limits here. Will update this issue if there's a response.

@josephrocca
Copy link
Author

josephrocca commented May 23, 2023

Okay, so it looks like it's possible to get about an order of magnitude faster with some adjutments, like setting bufferedAmountLowThreshold, as explained here: https://bugs.chromium.org/p/chromium/issues/detail?id=1447329#c4

Demo: https://lgrahl.de/examples/dc/dc-speedtest.html

(I haven't tried to adapt the demo in my earlier comment based on the code in the above-linked demo, so I can't completely confirm whether that test is "fair" - especially since it runs in a single tab)

@szimek
Copy link
Owner

szimek commented May 24, 2023

@josephrocca Thanks! ShareDrop uses a really old Peer.js library, that was additionally modified to work with Firebase rather than its own signaling server. I thought about switching to something more modern like https://github.com/feross/simple-peer, but never had time to actually look into it.

@gabbelitoV2
Copy link

because it would have been fun if you updated

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

No branches or pull requests

3 participants