Implement Chromium tracing in SDK and some benchmark code under tests#85
Conversation
stephen-derosa
left a comment
There was a problem hiding this comment.
Thanks for implementing this looks great! Definitely double check copyright year on new files.
Also, I ran the utests locally but i wasn't able to find the trace jsons. I would have thought they'd be in /tmp/ based on this line but i dont see them there or in my client-sdk-cpp repo
| @@ -0,0 +1,56 @@ | |||
| /* | |||
| * Copyright 2024 LiveKit | |||
There was a problem hiding this comment.
Good catch, done with changing it to 2026 on all the relevant files.
There was a problem hiding this comment.
Sorry, I missed this file, now it should be fixed.
It is under the folder where you run the tests. For instance, if you are running the tests like ./build-release/bin/livekit_integration_tests, it will be in your repo root folder, and I git ignore them to avoid corrupting the workspace. |
|
@stephen-derosa could you please take another look ? |
stephen-derosa
left a comment
There was a problem hiding this comment.
will applications have the ability to turn tracing on? if so, will there be an associated tracing example?
In general looks good to me! One comment about date and one about including in livekit.h
| #include "room.h" | ||
| #include "room_delegate.h" | ||
| #include "room_event_types.h" | ||
| #include "tracing.h" |
There was a problem hiding this comment.
what is the reason for including this here if it doesnt get used?
There was a problem hiding this comment.
There was a problem hiding this comment.
The APIs at tracing.h is public:
bool startTracing(const std::string &trace_file_path,
const std::vectorstd::string &categories = {});
void stopTracing();
bool isTracingEnabled();
Developers can start / stop tracing based on their needs, by default it is stopped.
| @@ -0,0 +1,56 @@ | |||
| /* | |||
| * Copyright 2024 LiveKit | |||
There was a problem hiding this comment.
great this should be useful in the cpp throughput tests
Yes, that public interface is at tracing.h, they can call startTracing(const std::string &trace_file_path); to turn the tracing on. All the tests now enable the tracing, and also it has its own unit tests. |
no need to add an example then, maybe just a comment somewhere saying "to turn tracing on..." |
Sounds good. I added a section in README.md to explain how to start / stop tracing. BTW, I can't add the tracing to examples since we need to make a release first before changing the examples, otherwise things will break there. |
Summary
Description
This PR introduces a tracing infrastructure based on Chrome's trace event format, enabling performance profiling and latency measurement across the LiveKit C++ SDK.
Tracing Implementation
The tracing system provides:
See tests traces examples in the screen shoot

Public API (include/livekit/tracing.h):
bool startTracing(const std::string& trace_file_path,
const std::vectorstd::string& categories = {});
void stopTracing();
bool isTracingEnabled();
Benchmark Utilities
New utilities in src/tests/benchmark/ for test instrumentation:
Unit Tests
17 unit tests covering:
Test Plan
Tracing