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

What about the performance of yamux? It seems yamux speed down a lot of bandwidth. #24

Open
liudanking opened this issue Feb 5, 2016 · 5 comments
Assignees
Labels

Comments

@liudanking
Copy link

I write a simple tcp tunnel with yamux, and test the speed:

  • Direct link (client --> server): 64mbps ~ 75mbps
  • yamux (default config) as a tunnel with 1 stream (client --> yamux client --stream--> yamux server --> server) : 24mbps ~ 28mbps

From the rough test above, we may conclude that yamux speed down a lot of bandwidth. Is there any methods that can improve throughtput yamux?

@slackpad
Copy link
Contributor

slackpad commented Feb 5, 2016

Hi @liudanking can you share any of your benchmarking code? There are a lot of things that could affect performance such as your payload size relative to the default window size, as well as how your receiver was performing (there's back pressure on the sender through the window mechanism). Yamux itself is pretty lightweight, but it is a TCP-style implementation so can have complex behavior in some cases.

@liudanking
Copy link
Author

@slackpad Thank you for your attention. The test I wrote is not a real benchmark. It is simple:

  • client opens a local listener, then copies data betweem yamux stream and local connection:
go io.Copy(localConn, yamuxStream)
io.Copy(yamuxStream, localConn)
// test only, we do not handle error and close
  • server also opens a listener, which accepts yamux session, for each yamux stream, it opens a connection to local :80 port. Then it copies data between yamux stream and connection of server :80 port:
go io.Copy(yamuxStream, local80Conn)
io.Copy(local80Conn, yamuxStream)

All yamux related code uses the default config.

The ping between client and server is about 60~80ms.

@liudanking
Copy link
Author

I run the test with 2 streams. And every stream reaches 24mbps ~ 28mbps. So I think yamux does NOT cost a lot of bandwidth, it just falls back to a safe speed to avoid stream congestion.

One thing that is strange: the stream speed is always 28mbps when speed becomes stable.

The problem to speed up stream speed is converted to how to optimize yamux stream window control algorithm just at @slackpad mentioned.

I try to set the yamux session with config of MaxStreamWindowSize = 2 * initialStreamWindow, but nothing is changed. Any ideas to optimize stream window control.

@slackpad slackpad self-assigned this Mar 15, 2016
@xtaci
Copy link
Contributor

xtaci commented May 9, 2016

highly concern on this

@whyrusleeping
Copy link
Contributor

Just to chime in here a bit, ipfs uses yamux as the default stream multiplexer for all connections, on LAN connections i've seen some pretty impressive speeds (>100mbps). We do use many streams per transfer though, not just sending data over a single stream.

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

No branches or pull requests

4 participants