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.
Rust's asynchronous system is a collaborative model, which means that all Futures should not occupy the executor for a long time.
There is a risk of preemption when yamux uses a loop. There will be no obvious problems under a single connection. However, when a large number of connections exist, if yamux is occupied for a long time, it will affect the scheduling of the entire task system, especially when the CPU capacity is insufficient. It will become more and more obvious on the machine, the consequence is that the communication speed will be greatly jittered.
What are the problems with occupying the executor for a long time?
First, it will cause the work-steal trigger to become more frequent
Second, it will affect the drivers triggering
Generally, Future tasks use executor in the principle of proximity, and bind on an executor, triggering work-steal means that there is additional synchronization work
Here we specify the maximum upper limit of one poll. If yamux still needs to be executed, first yield out, perform other tasks, or execute itself again
ref: tokio-rs/tokio#3493