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

Use completion-based IO in valence_network #489

Open
rj00a opened this issue Aug 23, 2023 · 0 comments
Open

Use completion-based IO in valence_network #489

rj00a opened this issue Aug 23, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@rj00a
Copy link
Member

rj00a commented Aug 23, 2023

Describe the problem related to your feature request.

The new completion-based async IO APIs have the potential to improve performance for a few reasons. Unfortunately, tokio/mio is designed around the old readiness model (kqueue/epoll) and thus does not support io_uring on Linux, "io ring" on Windows, etc.

There may also be some performance to be gained by avoiding the overhead and "bloat" of the tokio runtime's task scheduler.

What solution would you like?

Abstract away the socket and HTTP request code in valence_network behind a Backend struct. Then, implement two backends:

  1. Backend based on monoio for Linux and macOS (Windows support coming soon?).
  2. Backend based on tokio for platforms not supported by monoio. (or if monoio feature flag is not enabled)

Then, measure if performance is improved with monoio under heavy load. If not, then the changes are likely not worth the complexity and maintenance burden.

To what extent does reqwest/hyper depend on tokio? That could be a problem. Other than a single HTTPS fetch for authentication, we don't need anything beyond plain TCP and UDP support.

What alternative(s) have you considered?

Instead of monoio, we could use...

  • tokio-uring. Maintained by the tokio project. I chose monoio because they claim to be more efficient and it has more platform support. Although the nightly compiler requirement is unfortunate.
  • glommio. Seems like a subset of what monoio offers. Although no nightly requirement.
  • io_uring low-level unsafe API. This is not ideal.

Additional context

See this article for the differences between readiness and completion models: https://www.ncameron.org/blog/async-io-fundamentals/

@rj00a rj00a added the enhancement New feature or request label Aug 23, 2023
@rj00a rj00a linked a pull request Feb 11, 2024 that will close this issue
11 tasks
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 a pull request may close this issue.

1 participant