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

network: batch getdata replies #2757

Merged
merged 1 commit into from
Oct 24, 2022
Merged

network: batch getdata replies #2757

merged 1 commit into from
Oct 24, 2022

Conversation

roman-khimov
Copy link
Member

This is not exactly the protocol-level batching as was tried in #1770 and proposed by neo-project/neo#2365, but it's a TCP-level change in that we now Write() a set of messages and given that Go sets up TCP sockets with TCP_NODELAY by default this is a substantial change, we have less packets generated with the same amount of data. It doesn't change anything on properly connected networks, but the ones with delays benefit from it a lot.

This also improves queueing because we no longer generate 32 messages to deliver on transaction's GetData, it's just one stream of bytes with 32 messages inside.

Do the same with GetBlocksByIndex, we can have a lot of messages there too.

But don't forget about potential peer DoS attacks, if a peer is to request a lot of big blocks we need to flush them before we process the whole set.

cpu_four_(30_wrk,_64K_pool,_200ms)
cpu_four_(30_wrk,_64K_pool)
cpu_seven_(30_wrk,_64K_pool,_200ms)
cpu_seven_(30_wrk,_64K_pool)
mem_four_(30_wrk,_64K_pool,_200ms)
mem_four_(30_wrk,_64K_pool)
mem_seven_(30_wrk,_64K_pool,_200ms)
mem_seven_(30_wrk,_64K_pool)
ms_per_block_four_(30_wrk,_64K_pool,_200ms)
ms_per_block_four_(30_wrk,_64K_pool)
ms_per_block_seven_(30_wrk,_64K_pool,_200ms)
ms_per_block_seven_(30_wrk,_64K_pool)
tpb_four_(30_wrk,_64K_pool,_200ms)
tpb_four_(30_wrk,_64K_pool)
tpb_seven_(30_wrk,_64K_pool,_200ms)
tpb_seven_(30_wrk,_64K_pool)
tps_four_(30_wrk,_64K_pool,_200ms)
tps_four_(30_wrk,_64K_pool)
tps_seven_(30_wrk,_64K_pool,_200ms)
tps_seven_(30_wrk,_64K_pool)

@roman-khimov roman-khimov added network P2P layer performance More of something per second labels Oct 21, 2022
@roman-khimov roman-khimov added this to the v0.99.5 milestone Oct 21, 2022
This is not exactly the protocol-level batching as was tried in #1770 and
proposed by neo-project/neo#2365, but it's a TCP-level change in that we now
Write() a set of messages and given that Go sets up TCP sockets with
TCP_NODELAY by default this is a substantial change, we have less packets
generated with the same amount of data. It doesn't change anything on properly
connected networks, but the ones with delays benefit from it a lot.

This also improves queueing because we no longer generate 32 messages to
deliver on transaction's GetData, it's just one stream of bytes with 32
messages inside.

Do the same with GetBlocksByIndex, we can have a lot of messages there too.

But don't forget about potential peer DoS attacks, if a peer is to request a
lot of big blocks we need to flush them before we process the whole set.
@codecov
Copy link

codecov bot commented Oct 21, 2022

Codecov Report

Merging #2757 (cfb5058) into master (bf4636f) will increase coverage by 0.06%.
The diff coverage is 35.00%.

@@            Coverage Diff             @@
##           master    #2757      +/-   ##
==========================================
+ Coverage   85.21%   85.28%   +0.06%     
==========================================
  Files         324      324              
  Lines       40150    40178      +28     
==========================================
+ Hits        34215    34265      +50     
+ Misses       4562     4537      -25     
- Partials     1373     1376       +3     
Impacted Files Coverage Δ
pkg/network/tcp_peer.go 29.20% <0.00%> (-0.41%) ⬇️
pkg/network/server.go 72.13% <38.88%> (-0.93%) ⬇️
pkg/core/transaction/transaction.go 86.66% <0.00%> (+1.48%) ⬆️
pkg/network/message.go 96.26% <0.00%> (+3.73%) ⬆️
pkg/services/oracle/request.go 63.18% <0.00%> (+5.00%) ⬆️
pkg/network/compress.go 76.00% <0.00%> (+12.00%) ⬆️
pkg/services/oracle/oracle.go 87.59% <0.00%> (+14.59%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@roman-khimov roman-khimov merged commit 52df03e into master Oct 24, 2022
@roman-khimov roman-khimov deleted the batched-getdata branch October 24, 2022 07:15
@roman-khimov roman-khimov mentioned this pull request Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
network P2P layer performance More of something per second
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants