1 Star 0 Fork 0

Wanhao Ma / mh-nl

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Melvin Hao Network Library (MH-NL)

简介

MH-NL 一个简易的网络库, 支持两种 io 多路复用方法。

  1. epoll: 采用 one loop per thread 思想实现,实现方式参考了 Muduo 中的 Multi-Reactor 实现方式, 在 epoll 监听到感兴趣的事件后, 分发给不同的线程由其线程内的事件循环去处理
  2. io_uring: 使用 Linux 内核中全新的异步 io 框架, 采用 one loop and io_uring per thread 思想实现. 无事件分发机制, 而是采用抢占式处理事件, 多个线程中的事件循环会争先进行 accept 操作, 抢到后使用线程内的 io_uring 处理后续 io 事件

Benchmark

使用本网络库用 epoll 和 io_uring 两种方式分别实现了 EPollEchoServer 和 IOUringEchoServer, 再使用 rust_echo_bench 工具对它们进行性能测试

测试条件: 腾讯云轻量应用服务器 Ubuntu Server 22.04 LTS 64bit, CPU 2 核, 内存 2 GB

EPollEchoServer (request-response/sec duration=15s)

Clients 1 50 300 500 1000
128 bytes 27302 72584 57071 55268 50892
512 bytes 27492 72876 58259 52485 49051
1024 bytes 27716 70787 56611 51147 48969

IOUringEchoServer (request-response/sec duration=15s)

Clients 1 50 300 500 1000
128 bytes 32618 94579 81107 71066 68165
512 bytes 32896 96809 79555 71571 62461
1024 bytes 32833 93911 79413 63723 61740
MIT License Copyright (c) 2023 Ma WanHao Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

自制简易 C++ 网络框架,支持 epoll 和 io_uring 两种 io 多路复用方法。 展开 收起
C++ 等 4 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/rolfma/mh-nl.git
git@gitee.com:rolfma/mh-nl.git
rolfma
mh-nl
mh-nl
master

搜索帮助