eth/protocols/handler: add packet sending condition, prevent send small packets frequently; #1776
+24
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
eth/protocols/handler: add packet sending condition, prevent sending small packets frequently;
When profiling the p2p nodes, I found that
sendPooledTransactionHashes
func wastes the most CPU time.After inspecting the egress packets, it only contains ~1.14 hash per msg with 2500 peers, which sends very small packets too frequently.
So if it's possible to let msg collect more data to send once?
Below is the optimised performance profile:
Now it contains ~13 hashes per msg with 1800 peers:
Rational
Here add new config params:
minTxPacketSize
= 1024, it's very hard to reach. When the size is reached, it will packet ~32 hashes per msg.;sendPacketTimeout
= 300 *time.Millisecond
, less time will cause more times sending, and large time will cause more data. I tried 500ms, it will packet > 20 hashes per msg.Changes
Notable changes: