Code Monkey home page Code Monkey logo

xe's Introduction

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

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

See Building xe below
cd 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 .

xe's People

Contributors

davidzeng0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

kovdan01

xe's Issues

Your code is great!

Just wanted to say thanks for open-sourcing this, I've used your repo to learn more about io_uring's API and performant I/O. And I really enjoy your style of C++ programming (C with a dash of C++, much more readable than most C++ code).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.