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

[Merged by Bors] - p2p: server: adjust deadline during long reads and writes #5463

Closed
wants to merge 9 commits into from

Conversation

ivan4th
Copy link
Contributor

@ivan4th ivan4th commented Jan 18, 2024

Motivation

Currently, if a request takes too long to complete due to the data size and/or the speed of network connection, the requests often time out before the completion. This happens because stream deadline is set just once at the start of the request and not updated till it is completed. The timeouts cause a lot of i/o deadline exceeded errors, and also cause the nodes with high peer counts to be hammered by repeated retries by peers that fail to get ATX ID list for epoch, ActiveSets etc. Moreover, nodes may prevent themselves from retrieving the full response to request they make because of the timeouts.

Changes

In p2p/server, split large reads / writes into 4 KiB chunks. Update stream deadline after each chunk is read/written.

Test Plan

Verified the approach to work using emulated low-bandwidth node-to-node sync env: https://gist.github.com/ivan4th/c8add0b4d6a6fffb3da248b6b6bac346
Verified the approach to work on a node with high peer count
Verified normal mainnet syncing

Copy link

codecov bot commented Jan 18, 2024

Codecov Report

Attention: 17 lines in your changes are missing coverage. Please review.

Comparison is base (dd1fa87) 77.6% compared to head (aee761f) 77.6%.
Report is 18 commits behind head on develop.

Files Patch % Lines
p2p/server/server.go 57.5% 14 Missing ⚠️
p2p/server/deadline_adjuster.go 96.7% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #5463    +/-   ##
========================================
  Coverage     77.6%   77.6%            
========================================
  Files          267     268     +1     
  Lines        30956   31184   +228     
========================================
+ Hits         24045   24224   +179     
- Misses        5396    5431    +35     
- Partials      1515    1529    +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ivan4th
Copy link
Contributor Author

ivan4th commented Jan 18, 2024

bors try

spacemesh-bors bot added a commit that referenced this pull request Jan 18, 2024
@spacemesh-bors
Copy link

try

Build succeeded:

p2p/server/deadline_adjuster.go Outdated Show resolved Hide resolved
p2p/server/deadline_adjuster.go Outdated Show resolved Hide resolved
p2p/server/deadline_adjuster.go Show resolved Hide resolved
p2p/server/deadline_adjuster.go Outdated Show resolved Hide resolved
p2p/server/deadline_adjuster.go Show resolved Hide resolved
p2p/server/deadline_adjuster_test.go Show resolved Hide resolved
p2p/server/server.go Outdated Show resolved Hide resolved
@ivan4th
Copy link
Contributor Author

ivan4th commented Jan 25, 2024

bors merge

spacemesh-bors bot pushed a commit that referenced this pull request Jan 25, 2024
## Motivation
Currently, if a request takes too long to complete due to the data size and/or the speed of network connection, the requests often time out before the completion. This happens because stream deadline is set just once at the start of the request and not updated till it is completed. The timeouts cause a lot of `i/o deadline exceeded` errors, and also cause the nodes with high peer counts to be hammered by repeated retries by peers that fail to get ATX ID list for epoch, ActiveSets etc. Moreover, nodes may prevent themselves from retrieving the full response to request they make because of the timeouts.

## Changes
In `p2p/server`, split large reads / writes into 4 KiB chunks. Update stream deadline after each chunk is read/written.

## Test Plan
Verified the approach to work using emulated low-bandwidth node-to-node sync env: https://gist.github.com/ivan4th/c8add0b4d6a6fffb3da248b6b6bac346
Verified the approach to work on a node with high peer count
Verified normal mainnet syncing

Co-authored-by: Ivan Shvedunov <[email protected]>
@spacemesh-bors
Copy link

Pull request successfully merged into develop.

Build succeeded:

@spacemesh-bors spacemesh-bors bot changed the title p2p: server: adjust deadline during long reads and writes [Merged by Bors] - p2p: server: adjust deadline during long reads and writes Jan 25, 2024
@spacemesh-bors spacemesh-bors bot closed this Jan 25, 2024
@spacemesh-bors spacemesh-bors bot deleted the feature/adjust-deadline branch January 25, 2024 21:42
ivan4th added a commit that referenced this pull request Jan 25, 2024
## Motivation
Currently, if a request takes too long to complete due to the data size and/or the speed of network connection, the requests often time out before the completion. This happens because stream deadline is set just once at the start of the request and not updated till it is completed. The timeouts cause a lot of `i/o deadline exceeded` errors, and also cause the nodes with high peer counts to be hammered by repeated retries by peers that fail to get ATX ID list for epoch, ActiveSets etc. Moreover, nodes may prevent themselves from retrieving the full response to request they make because of the timeouts.

## Changes
In `p2p/server`, split large reads / writes into 4 KiB chunks. Update stream deadline after each chunk is read/written.

## Test Plan
Verified the approach to work using emulated low-bandwidth node-to-node sync env: https://gist.github.com/ivan4th/c8add0b4d6a6fffb3da248b6b6bac346
Verified the approach to work on a node with high peer count
Verified normal mainnet syncing

Co-authored-by: Ivan Shvedunov <[email protected]>
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.

2 participants