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

feat: reduce stream idle timeout to 1m #441

Merged
merged 1 commit into from
Jan 28, 2020
Merged

Conversation

Stebalien
Copy link
Member

It's currently 10 minutes. This change will kill all inbound DHT streams that haven't been used in 1 minute.

We keep streams around to avoid the cost of setting up new streams (the multistream overhead, mostly). However, each one of these takes at least one goroutine and some other state.

Ideally, this will let us run multiple DHTs side-by-side without keeping one stream per peer per DHT open.

It's currently 10 minutes. This change will kill all inbound DHT streams that
haven't been used in 1 minute.

We keep streams around to avoid the cost of setting up new streams (the
multistream overhead, mostly). However, each one of these takes at least one
goroutine and some other state.

Ideally, this will let us run multiple DHTs side-by-side without keeping one
stream per peer per DHT open.
@aschmahmann aschmahmann assigned aschmahmann and raulk and unassigned aschmahmann Jan 23, 2020
Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

SGTM

@Stebalien Stebalien requested a review from raulk January 27, 2020 20:42
Copy link
Member

@raulk raulk left a comment

Choose a reason for hiding this comment

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

I’m fine with this as long as we remove old DHT protocol from the mix. That should enable us to pipeline the (sole) protocol re-selection with the request message, thus removing any RTT overhead caused by recreating the stream more frequently. Is that the case?

@Stebalien
Copy link
Member Author

That should enable us to pipeline the (sole) protocol re-selection with the request message, thus removing any RTT overhead caused by recreating the stream more frequently. Is that the case?

Once we've successfully negotiated a protocol once (and after identify), we'll select that protocol immediately without waiting from then on every time we open a new stream. Opening a new stream won't cost us a round trip, it'll just cost us:

  1. Some extra bytes for the multistream header.
  2. Some extra bytes to open the stream.
  3. An extra packet to reset the stream.

@Stebalien
Copy link
Member Author

TL;DR: after identify or successfully creating a single stream, we'll always pipeline the header (https://github.com/libp2p/go-libp2p/blob/76944c4fc848530530f6be36fb22b70431ca506c/p2p/host/basic/basic_host.go#L438)

@Stebalien Stebalien merged commit 61b639e into master Jan 28, 2020
@Stebalien Stebalien deleted the feat/reduce-idle-timeout branch January 28, 2020 01:18
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

Successfully merging this pull request may close these issues.

4 participants