A collection of C++ experiments, utilities, and benchmarks. The repository covers concurrent containers, coroutine examples, networking utilities, memory management, logging, and system-level helpers.
- DPDK
RTE_Ringand a C++17 free-lock queue implementation - CommandCenter synchronous and asynchronous wrappers
- Ceph-style hash helpers, alignment utilities, and CPU binding
- Memory pools, thread pools, timers, and an LRU cache
- C++20 coroutine, Asio, hook, and RPC examples
- A C++20-capable compiler
- CMake 3.8 or later
- Git, including submodule support
makefor the bundledliburingbuild- Python development headers and
pybind11for thecall_pythonexample
Initialize third-party dependencies and configure an out-of-source Release build:
git submodule update --init --recursive --depth 1
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j 1The top-level build currently includes the tools test suite, io_uring examples
and benchmark, coroutine examples, the C++-to-Python call_python example,
yalanting examples, Asio examples, and hook tests. Other directories listed in
the root CMakeLists.txt remain disabled.
doctooltest supports filtering by test-case name:
# Network tests and benchmarks
./build/tools_test/doctooltest --test-case='*network_*'
# Object-pool tests and benchmarks
./build/tools_test/doctooltest --test-case='*ObjectPool_*'
# Reliable UDP tests and benchmarks
./build/tools_test/doctooltest --test-case='*ReliableUDP_*'
# Serialization tests and benchmarks
./build/tools_test/doctooltest --test-case='*serialize_*'
# Raft leader-election tests
./build/tools_test/doctooltest --test-case='*Raft_*'
# Shared-memory component tests
./build/tools_test/doctooltest --test-case='*shm_*'
# Coroutine tests
./build/tools_test/doctooltest --test-case='*coroutine_*'
# timer manager tests
./build/tools_test/doctooltest --test-case='*TimerManager*'The top-level CMake build configures and installs the bundled liburing into
build/liburing/install; no manual in-tree build is required. Build and run
the EasyLog benchmark with:
cmake --build build --target uring_log_benchmark
./build/uring_log/uring_log_benchmarkThe following result writes 2,500,000 messages across five threads, with each message approximately 80 bytes:
spdlog synchronous system write: 2315607969 ns
easylog synchronous system write: 1359331896 ns
easylog asynchronous system write: 337628465 ns
easylog synchronous io_uring write: 1073387513 ns
easylog asynchronous io_uring write: 279847519 ns
The C++-to-Python example is included in the top-level build. Build and run it with:
cmake --build build --target call_python
./build/call_python/call_pythonTo build it independently, use the CMake project in call_python/ instead.
timermanager::v6::TimerManager uses a steady_clock deadline min-heap. Each
heap entry owns one timer, and the worker waits for the earliest heap deadline
rather than polling at a fixed interval.
auto& timer_manager = timermanager::v6::TimerManager::GetInstance();
const auto id = timer_manager.AddTimer(
std::chrono::milliseconds(10), [] { /* callback */ },
std::chrono::milliseconds(100));
timer_manager.CancelTimer(id);Set interval to zero for a one-shot timer. A repeating callback may cancel
itself with its returned TimerId; a cancelled timer is not rescheduled.
tcmalloc_sample shows how to use tcmalloc and check memory leak.install pprof first
export GOPROXY=https://goproxy.cn,direct
go install github.com/google/pprof@latest
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --target gperftools_all tcmalloc_sample
MALLOCSTATS=2 ./build/tcmalloc_sample/tcmalloc_sample
HEAPPROFILE=/tmp/leak_test HEAP_PROFILE_TIME_INTERVAL=5 ./build/tcmalloc_sample/tcmalloc_sampleif your prrogress use glibc's ptmalloc, run follow to use tcmalloc:
git clone https://github.com/gperftools/gperftools.git
cd gperftools
./autogen.sh
mkdir build && cd build
../configure --prefix=${PWD}/../install
make -j4
make install
LD_PRELOAD=/path/to/libtcmalloc.so HEAPPROFILE=/tmp/leak_test HEAP_PROFILE_TIME_INTERVAL=5 ./your_progressand then, check memory leak
export PATH=$PATH:$(go env GOPATH)/bin
pprof --base=/tmp/leak_test.0002.heap \
--text \
./your_progress \
/tmp/leak_test.0005.heap
pprof --text ./your_progress /tmp/leak_test.0001.heap
pprof --text ./your_progress /tmp/leak_test.0005.heapThese applications require MySQL support and are not currently enabled by the top-level CMake build.
An HTTP server that receives call information and stores it in a database. Requires C++17.
cd Trimule
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --target trimule -j 2
cmake --build build --target trimule_copyfileTo run with Docker:
cd Trimule
sh docker_build.sh
sh docker_run.shTo change the port, update docker_run.sh and conf/trimule_config.json.
An HTTP server for managing dialog sessions and storing them in a database. Requires C++17.
cd Dialogmanager
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --target dialogmanager -j 1Configuration: conf/dialog_manager_config.json.
- Optimize
timermanagerwith a map-and-list design - Add a work-pool/object-pool path for large-message receiving
- Support multi-message sending with reliable UDP
- Decouple flow control from received-message counts