Skip to content

Commit 8b0f8a5

Browse files
Benchmark: data track throughput, csv generation and visualization (#111)
1 parent 332008c commit 8b0f8a5

12 files changed

Lines changed: 2289 additions & 19 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ Updates to ./build.sh and ./build.cmd should be accompanied by updates to this f
103103
./build.sh release-tests # Release build with tests
104104
./build.sh release-examples # Release build with examples
105105
./build.sh build-all # All of the above
106-
./build.sh clean # Clean build artifacts
107-
./build.sh clean-all # Full clean (C++ + Rust targets)
106+
./build.sh clean # Clean build artifacts + local-install
107+
./build.sh clean-all # Full clean (C++ + local-install + Rust targets)
108108
```
109109

110110
**Requirements:** CMake 3.20+, C++17, Rust toolchain (cargo), protoc. On macOS: `brew install cmake ninja protobuf abseil spdlog`. On Linux: see the CI workflow for apt packages.

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ git lfs pull
6060

6161
**Linux/macOS:**
6262
```bash
63-
./build.sh clean # Clean CMake build artifacts
64-
./build.sh clean-all # Deep clean (C++ + Rust + generated files)
63+
./build.sh clean # Clean CMake build artifacts + local-install
64+
./build.sh clean-all # Deep clean (C++ + Rust + local-install + generated files)
6565
./build.sh debug # Build Debug version
6666
./build.sh release # Build Release version
6767
./build.sh debug-examples # Build Debug with examples
@@ -74,8 +74,8 @@ git lfs pull
7474
**Windows**
7575
Using build scripts:
7676
```powershell
77-
.\build.cmd clean # Clean CMake build artifacts
78-
.\build.cmd clean-all # Deep clean (C++ + Rust + generated files)
77+
.\build.cmd clean # Clean CMake build artifacts + local-install
78+
.\build.cmd clean-all # Deep clean (C++ + Rust + local-install + generated files)
7979
.\build.cmd debug # Build Debug version
8080
.\build.cmd release # Build Release version
8181
.\build.cmd debug-examples # Build Debug with examples
@@ -135,14 +135,15 @@ cmake --build --preset macos-release
135135
📖 **For complete build instructions, troubleshooting, and platform-specific notes, see [README_BUILD.md](README_BUILD.md)**
136136

137137
### Building with Docker
138-
The Dockerfile COPYs folders/files required to build the CPP SDK into the image.
138+
The Docker setup is split into a reusable base image and an SDK image layered on top of it.
139139
**NOTE:** this has only been tested on Linux
140140
```bash
141-
docker build -t livekit-cpp-sdk . -f docker/Dockerfile
141+
docker build -t livekit-cpp-sdk-base . -f docker/Dockerfile.base
142+
docker build --build-arg BASE_IMAGE=livekit-cpp-sdk-base -t livekit-cpp-sdk . -f docker/Dockerfile.sdk
142143
docker run -it --network host livekit-cpp-sdk:latest bash
143144
```
144145

145-
__NOTE:__ if you are building your own Dockerfile, you will likely need to set the same `ENV` variables as in `docker/Dockerfile`, but to the relevant directories:
146+
__NOTE:__ if you are building your own Dockerfile, you will likely need to set the same `ENV` variables as in `docker/Dockerfile.base`, but to the relevant directories:
146147
```bash
147148
export CC=$HOME/gcc-14/bin/gcc
148149
export CXX=$HOME/gcc-14/bin/g++
@@ -487,7 +488,7 @@ cargo build -p yuv-sys -vv
487488
```
488489

489490
### Full clean (Rust + C++ build folders)
490-
In some cases, you may need to perform a full clean that deletes all build artifacts from both the Rust and C++ folders:
491+
In some cases, you may need to perform a full clean that deletes all build artifacts from both the Rust and C++ folders, plus the local install folder:
491492
```bash
492493
./build.sh clean-all
493494
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*env*/
2+
*/__pycache__/
3+
*throughput_results/*
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Copyright 2026 LiveKit, Inc.
2+
#
3+
# Standalone CMake build for the data-track throughput experiment.
4+
# All paths are relative to CMAKE_CURRENT_SOURCE_DIR so this directory
5+
# can be moved or renamed freely.
6+
7+
cmake_minimum_required(VERSION 3.20)
8+
project(DataTrackThroughput LANGUAGES CXX)
9+
10+
set(CMAKE_CXX_STANDARD 17)
11+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
12+
13+
# ---- Dependencies --------------------------------------------------------
14+
15+
find_package(LiveKit CONFIG REQUIRED)
16+
17+
find_package(nlohmann_json 3.11 QUIET)
18+
if(NOT nlohmann_json_FOUND)
19+
include(FetchContent)
20+
FetchContent_Declare(
21+
nlohmann_json
22+
GIT_REPOSITORY https://github.com/nlohmann/json.git
23+
GIT_TAG v3.11.3
24+
GIT_SHALLOW TRUE
25+
)
26+
FetchContent_MakeAvailable(nlohmann_json)
27+
endif()
28+
29+
# ---- Targets -------------------------------------------------------------
30+
31+
set(_targets DataTrackThroughputProducer DataTrackThroughputConsumer)
32+
33+
add_executable(DataTrackThroughputProducer producer.cpp)
34+
add_executable(DataTrackThroughputConsumer consumer.cpp)
35+
36+
foreach(_target ${_targets})
37+
target_include_directories(${_target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
38+
target_link_libraries(${_target} PRIVATE LiveKit::livekit nlohmann_json::nlohmann_json)
39+
endforeach()
40+
41+
# ---- RPATH ---------------------------------------------------------------
42+
43+
if(UNIX)
44+
if(APPLE)
45+
set_target_properties(${_targets} PROPERTIES
46+
BUILD_RPATH "@loader_path"
47+
INSTALL_RPATH "@loader_path"
48+
)
49+
else()
50+
set_target_properties(${_targets} PROPERTIES
51+
BUILD_RPATH "$ORIGIN"
52+
INSTALL_RPATH "$ORIGIN"
53+
BUILD_RPATH_USE_ORIGIN TRUE
54+
)
55+
endif()
56+
endif()
57+
58+
# ---- Copy SDK shared libraries next to executables -----------------------
59+
60+
get_target_property(_lk_location LiveKit::livekit IMPORTED_LOCATION)
61+
if(NOT _lk_location)
62+
get_target_property(_lk_location LiveKit::livekit IMPORTED_LOCATION_RELEASE)
63+
endif()
64+
if(NOT _lk_location)
65+
get_target_property(_lk_location LiveKit::livekit IMPORTED_LOCATION_DEBUG)
66+
endif()
67+
if(_lk_location)
68+
get_filename_component(_lk_lib_dir "${_lk_location}" DIRECTORY)
69+
endif()
70+
71+
if(_lk_lib_dir)
72+
if(WIN32)
73+
file(GLOB _sdk_shared_libs "${_lk_lib_dir}/../bin/*.dll" "${_lk_lib_dir}/*.dll")
74+
elseif(APPLE)
75+
file(GLOB _sdk_shared_libs "${_lk_lib_dir}/*.dylib")
76+
else()
77+
file(GLOB _sdk_shared_libs "${_lk_lib_dir}/*.so" "${_lk_lib_dir}/*.so.*")
78+
endif()
79+
80+
foreach(_target ${_targets})
81+
foreach(_lib ${_sdk_shared_libs})
82+
get_filename_component(_lib_name "${_lib}" NAME)
83+
add_custom_command(TARGET ${_target} POST_BUILD
84+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
85+
"${_lib}" "$<TARGET_FILE_DIR:${_target}>/${_lib_name}"
86+
COMMENT "Copying ${_lib_name} next to ${_target}"
87+
)
88+
endforeach()
89+
endforeach()
90+
endif()

0 commit comments

Comments
 (0)