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

Remeasure round trip time #70

Merged
merged 6 commits into from
Sep 7, 2022
Merged

Remeasure round trip time #70

merged 6 commits into from
Sep 7, 2022

Conversation

hannahhoward
Copy link
Contributor

@hannahhoward hannahhoward commented Jan 6, 2022

Goals

Keep round trip time up to date. This just updates the measured round trip time any time the keep alive timeout is called.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... this won't run if:

  1. Keep alives are disabled.
  2. We're actively receiving data (we defer keepalives when that happens).

@BigLep
Copy link

BigLep commented Aug 26, 2022

2022-08-26 conversation: we're wondering if this is the right fix or whether transports expose a RTT. Next step is for @marten-seemann to review again and figure out next steps. We will do this for this 0.23 go-libp2p release.

@marten-seemann marten-seemann requested review from Stebalien and MarcoPolo and removed request for marten-seemann September 5, 2022 13:11
@marten-seemann
Copy link
Contributor

I made a few changes to this PR:

  • simplified the timer logic by using a time.Ticker
  • calculate a smoothed RTT by taking the average between the last RTT estimate and the new measurement. Note that this is using a different ratio than QUIC, since we're only generating RTT measurements every 30s

@marten-seemann marten-seemann mentioned this pull request Sep 6, 2022
@@ -335,7 +335,25 @@ func (s *Session) measureRTT() {
if err != nil {
return
}
atomic.StoreInt64(&s.rtt, rtt.Nanoseconds())
if !atomic.CompareAndSwapInt64(&s.rtt, 0, rtt.Nanoseconds()) {
prev := atomic.LoadInt64(&s.rtt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this is no longer atomic, is that okay?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is. Worst thing that can happen is that we read the RTT again in getRTT. I agree that it's ugly.

@marten-seemann marten-seemann merged commit 48aa3a7 into master Sep 7, 2022
zllovesuki pushed a commit to zllovesuki/go-yamux that referenced this pull request Jan 23, 2023
* feat(session): remeasure round trip time

periodically re-measure round trip time

* feat(session): measure rtt during keep-alive

* refactor(session): repeat measure rtt via timer

* fix(session): fix flaky test

* simplify RTT timer by using a time.Ticker

* calculate a smoothed RTT

Co-authored-by: Marten Seemann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants