https://github.com/bytedance/monoio

Rust async runtime based on io-uring.

https://github.com/bytedance/monoio

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 46 committers (2.2%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.3%) to scientific vocabulary

Keywords from Contributors

argument-parser distribution observability tracing azblob gcs projection cloud-native sequences generic
Last synced: 10 months ago · JSON representation

Repository

Rust async runtime based on io-uring.

Basic Info
  • Host: GitHub
  • Owner: bytedance
  • License: apache-2.0
  • Language: Rust
  • Default Branch: master
  • Homepage:
  • Size: 5.06 MB
Statistics
  • Stars: 4,619
  • Watchers: 49
  • Forks: 255
  • Open Issues: 65
  • Releases: 20
Created over 4 years ago · Last pushed 11 months ago
Metadata Files
Readme Contributing License Security

README-zh.md

Monoio

一个基于 io_uring/epoll/kqueue 和 thread-per-core 模型 Rust Runtime。

Crates.io MIT/Apache-2 licensed Build Status Codecov English Readme

设计目标

作为一个基于 io_uring/epoll/kqueue 的 Runtime,Monoio 目标是在兼顾平台兼容性的情况下,做最高效、性能最优的 thread-per-core Rust Runtime。

我们的出发点很简单:跨线程任务调度会带来额外开销,且对 Task 本身有 SendSync 约束,导致无法很好地使用 thread local storage。而很多场景并不需要跨线程调度。如 nginx 这种负载均衡代理,我们往往可以以 thread-per-core 的模式编写。这样可以减少跨线程通信的开销,提高性能;也可以尽可能地利用 thread local 来做极低成本的任务间通信。当任务不需要被跨线程调度时,它就没有了实现 SendSync 的约束。另一点是 iouring 相比 epoll 在性能上有很大提升,我们也希望能够尽可能利用它达到最佳性能。所以基于 iouring 做一套 thread-per-core 的 Runtime 理论上可以获得一些场景下的最佳性能。

Monoio 就是这样一个 Runtime:它并不像 Tokio 那样通过公平调度保证通用性,它的目标是在特定场景下(thread per core 模型并不适用于所有场景)提供最好的性能。为了性能,Monoio 还开启了 GAT 等一系列的 unstable feature;同时也提供了全新的无拷贝的 IO 抽象。

功能上目前支持了部分网络 IO 和计时器;也支持跨线程异步通信。

我们的基准测试 表明 Monoio 比其他常见的 Rust 运行时具有更好的性能。

快速上手

要使用 Monoio,你需要最新的 nightly 工具链。如果你已经安装了 nightly 工具链,请确保是最新的版本。

在项目中创建 rust-toolchain 文件并在其中写入 nightly 即可强制指定;也可以使用 cargo +nightly 来构建或运行。

同时,如果你想使用 io_uring,你需要确保你当前的内核版本是较新的(5.6+);并且 memlock 是一个合适的配置。如果你的内核版本不满足需求,可以尝试使用 legacy driver 启动(参考这里),当前支持 Linux 和 macOS。

🚧实验性的 windows 系统支持正在开发中。

这是一个非常简单的例子,基于 Monoio 实现一个简单的 echo 服务。运行起来之后你可以通过 nc 127.0.0.1 50002 来连接它。

``rust,no_run /// A echo example. /// /// Run the example andnc 127.0.0.1 50002` in another shell. /// All your input will be echoed out. use monoio::io::{AsyncReadRent, AsyncWriteRentExt}; use monoio::net::{TcpListener, TcpStream};

[monoio::main]

async fn main() { let listener = TcpListener::bind("127.0.0.1:50002").unwrap(); println!("listening"); loop { let incoming = listener.accept().await; match incoming { Ok((stream, addr)) => { println!("accepted a connection from {}", addr); monoio::spawn(echo(stream)); } Err(e) => { println!("accepted connection failed: {}", e); return; } } } }

async fn echo(mut stream: TcpStream) -> std::io::Result<()> { let mut buf: Vec = Vec::with_capacity(8 * 1024); let mut res; loop { // read (res, buf) = stream.read(buf).await; if res? == 0 { return Ok(()); }

    // write all
    (res, buf) = stream.write_all(buf).await;
    res?;

    // clear
    buf.clear();
}

} ```

在本仓库的 examples 目录中有更多的例子。

限制

  1. 在 Linux 5.6 或更新版本上,Monoio 可以以 uring 或 epoll 作为可选驱动方式,低版本 Linux 上只能以 epoll 方式运行,在 macOS 上可以使用 kqueue。其他平台暂不支持。
  2. Monoio 这种 thread per core 的 runtime 并不适用于任意场景。如果负载非常不均衡,相比公平调度模型的 Tokio 它可能会性能变差,因为 CPU 利用可能不均衡,不能充分利用可用核心。

贡献者

在此表示感谢!

社区

Monoio 是 CloudWego 的子项目,我们致力于建设云原生生态系统。

关联项目

HTTP 框架和 RPC 框架在做了在做了(咕咕咕)。

协议

Monoio 基于 MIT 或 Apache 协议授权。

在开发中我们大量参考了 Tokio, Mio, Tokio-uring 和其他一些项目,在此向这些项目的贡献者们表示感谢。

Owner

  • Name: Bytedance Inc.
  • Login: bytedance
  • Kind: organization
  • Location: Singapore

GitHub Events

Total
  • Issues event: 26
  • Watch event: 668
  • Member event: 2
  • Issue comment event: 70
  • Push event: 18
  • Pull request review event: 61
  • Pull request review comment event: 39
  • Pull request event: 38
  • Fork event: 40
  • Create event: 1
Last Year
  • Issues event: 26
  • Watch event: 668
  • Member event: 2
  • Issue comment event: 70
  • Push event: 18
  • Pull request review event: 61
  • Pull request review comment event: 39
  • Pull request event: 38
  • Fork event: 40
  • Create event: 1

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 195
  • Total Committers: 46
  • Avg Commits per committer: 4.239
  • Development Distribution Score (DDS): 0.446
Past Year
  • Commits: 36
  • Committers: 14
  • Avg Commits per committer: 2.571
  • Development Distribution Score (DDS): 0.639
Top Committers
Name Email Commits
ihc童鞋@提不起劲 i****h@g****m 108
Lzzzt 1****t 13
loongs-zhang z****g@a****g 9
Jin Wei Tan 4****3 5
dependabot[bot] 4****] 4
李冬冬 l****i@1****m 4
Harsha h****k@g****m 4
Hao Xiang h****o@o****m 3
bobozhengsir b****r@g****m 3
NKID00 t****s@n****e 3
misssonder 8****8@q****m 2
Xuanwo g****b@x****o 2
Zhanhui Li l****i@g****m 2
0x29a l****9@g****m 1
Alex Kladov a****v@g****m 1
Andrew Duffy a****y 1
Anthony Griffon a****n@g****m 1
Ben Pfaff b****p@c****u 1
Gerd Zellweger m****l@g****m 1
Guillem L. Jara 4****0@t****m 1
Ivan Tham p****e@r****t 1
John a****n@i****t 1
Juan Aguilar m****n@g****m 1
Kingtous k****e@g****m 1
reloginn 6****n 1
neetdai 9****6@q****m 1
lz1998 8****3@q****m 1
loris libralato l****1@g****m 1
lixiang365 1****5 1
liuxin 3****1 1
and 16 more...
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 99
  • Total pull requests: 243
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 11 days
  • Total issue authors: 68
  • Total pull request authors: 46
  • Average comments per issue: 1.3
  • Average comments per pull request: 0.78
  • Merged pull requests: 190
  • Bot issues: 0
  • Bot pull requests: 12
Past Year
  • Issues: 26
  • Pull requests: 58
  • Average time to close issues: 22 days
  • Average time to close pull requests: 7 days
  • Issue authors: 21
  • Pull request authors: 15
  • Average comments per issue: 0.35
  • Average comments per pull request: 0.71
  • Merged pull requests: 40
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Xuanwo (5)
  • xj524598 (5)
  • NKID00 (4)
  • ouvaa (4)
  • hiqsociety (3)
  • ihciah (3)
  • Lzzzzzt (3)
  • SteveLauC (2)
  • kolinfluence (2)
  • botika (2)
  • dyxushuai (2)
  • GodGavin (2)
  • likeabbas (2)
  • SuanCaiYv (2)
  • trickster (2)
Pull Request Authors
  • ihciah (84)
  • Lzzzzzt (25)
  • loongs-zhang (19)
  • dependabot[bot] (12)
  • kaspar030 (10)
  • hxzhao527 (7)
  • Xuanwo (7)
  • har23k (5)
  • NKID00 (5)
  • dragon-zhang (4)
  • SteveLauC (4)
  • CarrotzRule123 (4)
  • misssonder (4)
  • ethe (4)
  • tshepang (4)
Top Labels
Issue Labels
F-feature-request (61) bug (1)
Pull Request Labels
dependencies (12)

Packages

  • Total packages: 3
  • Total downloads:
    • cargo 371,483 total
  • Total dependent packages: 31
    (may contain duplicates)
  • Total dependent repositories: 19
    (may contain duplicates)
  • Total versions: 42
  • Total maintainers: 2
crates.io: monoio

A thread per core runtime based on iouring.

  • Documentation: https://docs.rs/monoio/
  • License: MIT OR Apache-2.0
  • Latest release: 0.2.4
    published almost 2 years ago
  • Versions: 26
  • Dependent Packages: 26
  • Dependent Repositories: 11
  • Downloads: 205,966 Total
Rankings
Dependent packages count: 2.2%
Stargazers count: 2.3%
Forks count: 4.4%
Average: 6.0%
Dependent repos count: 7.6%
Downloads: 13.3%
Maintainers (1)
Last synced: 11 months ago
crates.io: monoio-macros

Monoio proc macros.

  • Versions: 4
  • Dependent Packages: 1
  • Dependent Repositories: 7
  • Downloads: 141,729 Total
Rankings
Stargazers count: 2.3%
Forks count: 4.4%
Dependent repos count: 8.7%
Average: 9.5%
Downloads: 14.0%
Dependent packages count: 18.2%
Maintainers (1)
Last synced: 11 months ago
crates.io: monoio-compat

A compat wrapper for monoio.

  • Versions: 12
  • Dependent Packages: 4
  • Dependent Repositories: 1
  • Downloads: 23,788 Total
Rankings
Stargazers count: 2.3%
Forks count: 4.4%
Average: 11.7%
Dependent packages count: 12.2%
Dependent repos count: 16.5%
Downloads: 23.2%
Maintainers (2)
Last synced: 11 months ago

Dependencies

.github/workflows/cargo-deny.yml actions
  • EmbarkStudios/cargo-deny-action v1 composite
  • actions/checkout v2 composite
.github/workflows/ci.yml actions
  • Swatinem/rust-cache v1 composite
  • actions-rs/cargo v1 composite
  • actions-rs/toolchain v1 composite
  • actions/checkout v2 composite
.github/workflows/coverage.yml actions
  • Swatinem/rust-cache v1 composite
  • actions-rs/cargo v1 composite
  • actions-rs/toolchain v1 composite
  • actions/checkout v2 composite
.github/workflows/pr-audit.yml actions
  • actions-rs/cargo v1 composite
  • actions/checkout v2 composite
monoio/Cargo.toml cargo
  • futures 0.3 development
  • local-sync 0.0.5 development
  • tempfile 3.2 development
  • auto-const-array 0.2
  • bytes 1
  • flume 0.10
  • fxhash 0.2
  • libc 0.2
  • mio 0.8
  • monoio-macros 0.0.3
  • pin-project-lite 0.2
  • socket2 0.4
  • threadpool 1
  • tokio 1
  • tracing 0.1
monoio-compat/Cargo.toml cargo
  • monoio 0.0.9 development
  • monoio 0.0.9
  • reusable-box-future 0.2
  • tokio 1
Cargo.toml cargo
examples/Cargo.toml cargo
monoio-macros/Cargo.toml cargo