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

ref(project-cache): Yield back to runtime in expensive branches #4240

Closed
wants to merge 1 commit into from

Conversation

Dav1dde
Copy link
Member

@Dav1dde Dav1dde commented Nov 12, 2024

Be a bit more cooperative for the runtime and yield back after expensive messages.

Eviction is quite costly for large projects, and with scheduled fetches being biased towards it's possible that we do this a lot before being force yielded by the runtime.

#skip-changelog

@Dav1dde Dav1dde requested a review from a team as a code owner November 12, 2024 07:26
@Dav1dde Dav1dde self-assigned this Nov 12, 2024
Copy link
Member

@jjbayer jjbayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the purpose of this to prevent the project cache service from hogging the runtime, and increasing the probability that other services make progress?

Wouldn't the runtime itself already be pretty good at this?

As of 0.2.14, each Tokio task has an operation budget.

https://tokio.rs/blog/2020-04-preemption

@Dav1dde
Copy link
Member Author

Dav1dde commented Nov 12, 2024

Wouldn't the runtime itself already be pretty good at this?

Yes it is, but we can still give it a few hints, especially for the eviction branch, the eviction worst case is taking 50ms of CPU, but that does not decrease the cooperative budget, because it is a purely synchronous call and nothing is using the budget. So even after doing that long task, the runtime spends time on the task.

See #4241 to eliminate this long running blocking task, which is probably the better approach.

@Dav1dde
Copy link
Member Author

Dav1dde commented Nov 14, 2024

No longer necessary with #4241.

@Dav1dde Dav1dde closed this Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants