xe
Hyper Fast io_uring Async I/O Library
Documentation is still WIP
Features
xe
- High Performance
- Low Latency I/O
- Fast Nanosecond Precision Timers
- Ultra Lightweight (0.6% overhead for echoserver)
xe/io
- Socket and File classes and utilities
- Epoll/libuv-like fast poll handle
xurl (WIP)
- Async DNS resolution
- HTTP, WS, and FILE url protocols (WIP)
Benchmarks
Library | Speed | % |
---|---|---|
xe | 363K | 100.0 % |
l4cpp | 362K | 99.8 % |
frevib | 353K | 97.3 % |
epoll | 351K | 96.8 % |
photon | 305K | 84.1 % |
See benchmarks
Examples
// hello world snippet
static task run(xe_loop& loop){
char msg[] = "Hello World!\n";
co_await loop.queue(xe_op::write(STDOUT_FILENO, msg, sizeof(msg) - 1, 0));
}
Above snippet from hello_world.cc
// echo server snippet
static task echo(xe_socket& socket){
byte buf[16384];
int result;
while(true){
result = co_await socket.recv(buf, 16384, 0);
if(result <= 0)
break;
result = co_await socket.send(buf, result, 0);
if(result < 0)
break;
}
}
Above snippet from echoserver.cc
See examples and coroutine examples
Running Examples
Building xe below
Seecd build
./coroutine_hello_world
./timer
./coroutine_file
./http # only if xurl enabled with openssl or wolfssl
./coroutine_echoserver
./echoserver
Using
Prerequisites
- Linux Kernel 5.11 or later
- liburing
apt install liburing-dev
or install from source - cmake
apt install cmake
- g++ 10 or newer, or clang 12 or newer
apt install g++-10/clang++-12
xurl prerequisites (only if enabled, disabled by default)
- c-ares
apt install libc-ares-dev
or install from source
One of:
- OpenSSL >= 1.1.1
apt install libssl-dev
- wolfSSL (must be installed from source, see build flags)
Use with cmake
project(sample CXX)
# remove two lines below to disable xurl
set(XE_ENABLE_XURL ON)
set(XE_USE_OPENSSL ON) # alternatively set(XE_USE_WOLFSSL ON)
FetchContent_Declare(xe GIT_REPOSITORY https://github.com/davidzeng0/xe.git GIT_TAG master)
FetchContent_MakeAvailable(xe)
...
target_link_libraries(sample xe)
# with xurl
target_link_libraries(sample xe xurl)
Build xe
mkdir build; cd build
# with ninja
cmake -G "Ninja" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_CXX_COMPILER="/your/cxx/compiler" ..
# enable xurl and use openssl
cmake -G "Ninja" -DXE_ENABLE_XURL="ON" -DXE_USE_OPENSSL="ON" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_CXX_COMPILER="/your/cxx/compiler" ..
# without ninja
cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_CXX_COMPILER="/your/cxx/compiler" ..
cmake --build .