frevib / io_uring-echo-server Goto Github PK
View Code? Open in Web Editor NEWio_uring echo server
License: MIT License
io_uring echo server
License: MIT License
epoll-echo-server 单线程,高并发时,recv、send操作都是串行执行
uring-echo-server 单线程,高并发时,uring_read、uring_write的sqe在内核中是iou-wrk线程池并发执行
$ telnet 127.0.0.1 12345 13:58:11
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
1234567890
1234567890
12345
12345
890
expected:
$ telnet 127.0.0.1 12345 13:59:12
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
1234567890
1234567890
12345
12345
I faced the same issue during long running of the io_uring based server. Have u ever addressed this issue or have some insights about it?
$ ./io_uring_echo_server 1976
io_uring echo server listening for connections on port: 1976
from io_uring_echo-server main() sizeof(struct io_uring): 160
From io_uring_queue_mmap() sizeof(*ring): 216 sizeof(struct io_uring): 216
Before memset() in io_uring_queue_mmap(): p->sq_entries: 2048
After memset() in io_uring_queue_mmap(): p->sq_entries: 0
io_uring_init_failed...
: Invalid argument
Hi,
I do not see anything in your code that does something differently. what IORING_FEAT_FAST_POLL does and where exactly you use it? (besides testing it in the features)
Hi, I'm new to io_uring and I'm recently practicing using io_uring and using your code as a reference. I tried to modify the conn_info structure but found that the program was giving me errors, and it took me a long time to figure out that user_data only holds 64-bit data. I think your code may be misleading to people new to io_uring, although your conn_info structure happens to be 64-bit, but if you can, I suggest you store a pointer to conn_info in user_data, because the above problem really bothered me for two days :(
Using a fixed buffer gives unreliable results in with Rust echo bench
I have tested your epoll and io_uring examples and I get 250k (req/sec) with your epoll example and only 220k with io_uring. I also get 250k with my own epoll implementation so that confirms we are both using efficient use of epoll.
I'm running on Linux 5.7 Clear Linux - do you have any hints on how I can reproduce your results?
Hi,
Buffers are not being reused after calling io_uring_prep_provide_buffers(). To reproduce this error change:
#define MAX_CONNECTIONS 4096
to
#define MAX_CONNECTIONS 2
Then telnet to the echo server port, close the connection and repeat three times. The first time all works well as the first two buffers are used but on the third connection attempt io_uring runs out of buffers and returns "No buffer space available". I did some debugging and io_uring starts using buf id 1, then id 0 but on the third attempt rather than reusing any of the two available buffers it fails.
It might be a io_uring bug as the code looks fine. I'm using the 5.11 kernel.
Thanks.
Hello frevib!
I've just started to learn io_uring. I am getting a runtime error while running your io_uring code for echo server. It seems we can no longer use free()
to free probes. Here are my environments:
% pacman -Si liburing
Repository : extra
Name : liburing
Version : 2.4-1
Description : Linux-native io_uring I/O access library
Architecture : x86_64
URL : https://git.kernel.dk/cgit/liburing/
Licenses : LGPL2.1 MIT
Groups : None
Provides : liburing.so=2-64 liburing-ffi.so=2-64
Depends On : glibc
Optional Deps : None
Conflicts With : None
Replaces : None
Download Size : 160.30 KiB
Installed Size : 309.36 KiB
Packager : David Runge <[email protected]>
Build Date : Thu 08 Jun 2023 07:02:14 PM +08
Validated By : MD5 Sum SHA-256 Sum Signature
% uname -a
Linux relm 6.4.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 27 Jul 2023 22:02:18 +0000 x86_64 GNU/Linux
% g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.1.1 20230714 (GCC)
Cheers,
Fw[a]rd.
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.