-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: establish RTT at start of connection #64
Conversation
A connection ping is required to establish the RTT - as implemented the ping only happens during the keep alive loop that doesn't kick in until after 30s by default. The change is to ping immediately on sinking a source - this means we are more likely to increase the send window on the remote which increases the amount of data they send and as such, throughput.
@@ -274,7 +274,7 @@ export class YamuxStream extends AbstractStream { | |||
// then we (up to) double the recvWindow | |||
const now = Date.now() | |||
const rtt = this.getRTT() | |||
if (flags === 0 && rtt > 0 && now - this.epochStart < rtt * 4) { | |||
if (flags === 0 && rtt > -1 && now - this.epochStart < rtt * 4) { |
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.
RTT might be less than a ms on a very fast local connection?
🤷
@@ -45,9 +45,9 @@ describe('stream', () => { | |||
// the window capacities should have refilled via window updates as received data was consumed | |||
|
|||
// eslint-disable-next-line @typescript-eslint/dot-notation | |||
expect(c1['sendWindowCapacity']).to.equal(defaultConfig.initialStreamWindowSize) | |||
expect(c1['sendWindowCapacity']).to.be.gte(defaultConfig.initialStreamWindowSize) |
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.
These tests have become non-deterministic after this change, sometimes the window is the starting 256KB, sometimes it's been increased to 16MB by the time the test finishes.
I think this is one of the causes of the speed discrepancy between the js yamux and mplex implementations. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
📢 Thoughts on this report? Let us know! |
## [5.0.3](v5.0.2...v5.0.3) (2023-11-14) ### Bug Fixes * establish RTT at start of connection ([#64](#64)) ([672523b](672523b))
🎉 This PR is included in version 5.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
A connection ping is required to establish the RTT - as implemented the ping only happens during the keep alive loop that doesn't kick in until after 30s by default.
The change is to ping immediately on sinking a source - this means we are more likely to increase the send window on the remote which increases the amount of data they send and as such, throughput.