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

feat: prevent io starvation #3

Merged
merged 1 commit into from
Dec 6, 2021
Merged

feat: prevent io starvation #3

merged 1 commit into from
Dec 6, 2021

Conversation

ihciah
Copy link
Member

@ihciah ihciah commented Dec 5, 2021

Problem

Currently the main loop will wait for all tasks executed to do syscall enter. If a task can always generate a new one, other tasks will be starved since the task queue will never be empty and syscall will never be done.

Solution

Maybe we can add a quota to task(in TLS) on execute, like coop in tokio. Another easy way is to do submit(not submit_and_wait) at fixed loop times.

We take the solution 2. The loop times limit is set to task length * 2.

@ihciah ihciah requested review from dyxushuai and suikammd and removed request for dyxushuai and suikammd December 5, 2021 06:10
@ihciah ihciah self-assigned this Dec 5, 2021
@ihciah ihciah added the enhancement New feature or request label Dec 5, 2021
@ihciah
Copy link
Member Author

ihciah commented Dec 5, 2021

Question: is task length * 2 enough?

@dyxushuai
Copy link
Member

The coop in tokio used to prevent a task from running for a long time, different with this problem.
Maybe new issue will be open in next time when we need preemption.
ref: https://tokio.rs/blog/2020-04-preemption

@ihciah ihciah merged commit 7223e0d into master Dec 6, 2021
@ihciah ihciah deleted the feat/prevent-starvation branch December 6, 2021 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants