-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't timeout when receiving too many messages from choked peer
- Loading branch information
Showing
5 changed files
with
32 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
use std::time::Duration; | ||
|
||
// If a response to a pending request is not received within this time, a request timeout error is | ||
// triggered. | ||
/// If a response to a pending request is not received within this time, a request timeout error is | ||
/// triggered. | ||
pub(super) const REQUEST_TIMEOUT: Duration = Duration::from_secs(30); | ||
|
||
// Maximum number of request which have been sent but for which we haven't received a response yet. | ||
// Higher values give better performance but too high risks congesting the network. Also there is a | ||
// point of diminishing returns. 32 seems to be the sweet spot based on a simple experiment. | ||
/// Maximum number of requests that have been sent to a given peer but for which we haven't received | ||
/// a response yet. Higher values give better performance but too high risks congesting the | ||
/// network. There is also a point of diminishing returns. 32 seems to be the sweet spot based on a | ||
/// simple experiment. | ||
/// NOTE: This limit is protecting the peer against being overhelmed by too many requests from us. | ||
// TODO: run more precise benchmarks to find the actual optimum. | ||
pub(super) const MAX_REQUESTS_IN_FLIGHT: usize = 32; | ||
pub(super) const MAX_IN_FLIGHT_REQUESTS_PER_PEER: usize = 32; | ||
|
||
// Maximum number of respones that a `Client` received but had not yet processed before the client | ||
// is allowed to send more requests. | ||
pub(super) const MAX_PENDING_RESPONSES: usize = 2 * MAX_REQUESTS_IN_FLIGHT; | ||
/// Maximum number of requests that have been sent on a given `Client` but for which the response | ||
/// hasn't yet been processed (although it may have been received). | ||
/// NOTE: This limit is protecting us against being overhelmed by too many responses from the peer. | ||
pub(super) const MAX_PENDING_REQUESTS_PER_CLIENT: usize = 2 * MAX_IN_FLIGHT_REQUESTS_PER_PEER; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters