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

支持 Monoio 作为可选的 Runtime #3

Open
PureWhiteWu opened this issue Aug 10, 2022 · 8 comments
Open

支持 Monoio 作为可选的 Runtime #3

PureWhiteWu opened this issue Aug 10, 2022 · 8 comments
Assignees
Labels
A-volo This issue concerns the main`volo` crate. C-feature-accepted This feature request is accepted. E-hard This is hard.

Comments

@PureWhiteWu
Copy link
Member

Feature Request

Crates

影响所有的 crate。

Motivation

Monoio 是一个主要基于 io-uring 的 thread-per-core 的 runtime,在 thread-per-core 场景下性能很好。

支持 Monoio 作为可选的 runtime 可以使得我们的部分场景的用户获得巨大的性能提升,如 Proxy 场景用户和存储场景用户。

Proposal

首先,我们希望用户能够以较低的成本来在两个 Runtime 之间切换,例如使用 feature 的方式。我们可以定义两个 feature,如runtime-monoioruntime-tokio

接着,我们希望能够尽可能提高可维护性,因此我们可以把一些 runtime 相关的逻辑,抽象出来一个独立的包,例如叫做volo-rt,统一放到这个包里维护,并在其它 crate 中复用。

最后,我们需要找到所有直接依赖 tokio 的地方,改成依赖volo-rt或者通过条件编译改成 monoio 的方案。

要注意,有一些依赖库可能会直接依赖 tokio。

Alternatives

另一种可选的方案是,以牺牲一定性能为代价,尝试使用 monoio-compact 来兼容 Tokio。该方案可行性仍然待讨论。

@PureWhiteWu PureWhiteWu added A-volo This issue concerns the main`volo` crate. C-feature-accepted This feature request is accepted. E-hard This is hard. labels Aug 10, 2022
@ThaddeusTreloar
Copy link

Happy to be assigned this if you've not found anyone else.

I had a look through the source and the task doesn't look too bad. Even in the dependencies, it doesn't look like there are many calls to Tokio runtime specific code.

@PureWhiteWu
Copy link
Member Author

Wow! Great you would like to help!
We are redesigning our motore::Service trait to use rpitit, after that it will be more easy to support monoio as an opt-in runtime.

@ThaddeusTreloar
Copy link

ThaddeusTreloar commented Oct 19, 2023

I've done most of the preliminary work so that you can enable a feature flag and the runtime will swap. It currently continues to use non runtime specific Tokio components where possible (eg. AsyncRead/AsyncWrite).

The feature is currently blocked as there are several instances where a tokio::time::Sleep is returned in a future bound with Send. Unfortunately the Monoio equivalent is not thread safe and therefore not Send. I'm currently working to refactor the Monoio implementation (which is largely derived from Tokio 's version) to be Send.

@PureWhiteWu
Copy link
Member Author

PureWhiteWu commented Oct 20, 2023

@ThaddeusTreloar Hello, sorry for the late reply, I'm busy refactoring the Service trait these days.
I've finally refactored the Service trait in motore to use afit and rpitit, which can easily switch between Send and ?Send version by a feature flag.
And I've also migrated volo to use the new Service trait in motore in #239 .
You may try to overcome the Send problem now.

@iamazy
Copy link

iamazy commented Jan 2, 2024

I'm eager about this feature

@ThaddeusTreloar
Copy link

@PureWhiteWu sorry for the silence, I have been busy over the holiday season.
I am currently playing with the service_send feature, and I've come across a situation while completing the motore::make::make_connection::MakeConnection impl for volo::net::dial::DefaultMakeTransport.
Is there a reason why MakeConnection requires that Self::Connection (and in the case where UnaryService is implemented, Self::Connection) is Send?

@ThaddeusTreloar
Copy link

@PureWhiteWu let me know if I should move that question to the motore repository.

@ouvaa
Copy link

ouvaa commented Feb 26, 2024

@ThaddeusTreloar @PureWhiteWu looking forward to having monoio being used here too!

pls show the example hello_grpc_tls with h2 using monoio. thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-volo This issue concerns the main`volo` crate. C-feature-accepted This feature request is accepted. E-hard This is hard.
Development

No branches or pull requests

5 participants