Skip to content

feat: prevent io starvation#3

Merged
ihciah merged 1 commit intomasterfrom
feat/prevent-starvation
Dec 6, 2021
Merged

feat: prevent io starvation#3
ihciah merged 1 commit intomasterfrom
feat/prevent-starvation

Conversation

@ihciah
Copy link
Copy Markdown
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
Copy Markdown
Member Author

ihciah commented Dec 5, 2021

Question: is task length * 2 enough?

@dyxushuai
Copy link
Copy Markdown
Collaborator

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