Skip to content

Memory regression tests - #275

Open
alan-george-lk wants to merge 14 commits into
mainfrom
alan/feature-memory-regression-tests
Open

alan-george-lk wants to merge 14 commits into
mainfrom
alan/feature-memory-regression-tests

Conversation

@alan-george-lk

@alan-george-lk alan-george-lk commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

This PR introduces a new test binary called memory_tester for Linux, which has the following features:

  • Configurable common scenarios
    • Examples: publishing tracks, room joining/closure
  • RSS and thread usage tracking
  • Configurable repeated iterations, acceptable memory and thread growth bounds

CI is also updated to run this tester and provide a nice markdown table report of the results, and fail jobs that introduce changes that fail this.

Documentation is also updated around testing in general, as it was a bit out of date.

Results

Here are two FFI release results with the following params:

Iterations: 100
Warmup: 20
Threshold: RSS growth ≤ 8 MiB; thread growth ≤ 0.

Prior release livekit-ffi/v0.12.81 results:

Scenario RSS 0→20 RSS 20→100 Threads 0→20 Threads 20→100 Status
audio-track +60.63 MiB -2.64 MiB +28 0 ✅ PASS
video-track +61.43 MiB -2.62 MiB +28 0 ✅ PASS
data-track +53.88 MiB +0.03 MiB +2 0 ✅ PASS
room-reuse +53.54 MiB +3.47 MiB +2 0 ✅ PASS
room-client-leave +53.66 MiB +0.12 MiB +2 0 ✅ PASS
room-server-delete +143.46 MiB +108.94 MiB +105 +400 ❌ FAIL

Current FFI release results:

Scenario RSS 0→20 RSS 20→100 Threads 0→20 Threads 20→100 Status
audio-track +17.36 MiB +0.19 MiB +12 0 ✅ PASS
video-track +16.74 MiB -0.05 MiB +7 0 ✅ PASS
data-track +12.30 MiB +0.03 MiB +1 0 ✅ PASS
room-reuse +12.09 MiB 0.00 MiB +1 0 ✅ PASS
room-client-leave +12.10 MiB +0.05 MiB +1 0 ✅ PASS
room-server-delete +12.11 MiB +0.08 MiB +1 0 ✅ PASS

@alan-george-lk
alan-george-lk force-pushed the alan/feature-memory-regression-tests branch from 2a21a8a to d638cca Compare October 15, 2026 03:06
@alan-george-lk
alan-george-lk marked this pull request as ready for review October 15, 2026 23:35
@alan-george-lk
alan-george-lk requested review from a team and xianshijing-lk as code owners October 15, 2026 23:35
@alan-george-lk alan-george-lk changed the title WIP: Memory regression tests Memory regression tests Oct 15, 2026

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

🔍 Devin Review: 2 flags

Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

devin-ai-integration[bot]

This comment was marked as resolved.

@stephen-derosa stephen-derosa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks great, thanks for adding these!

matrix.e2e-testing &&
(inputs.integration_repeat > 0 ||
inputs.run_stress_tests ||
(matrix.name == 'ubuntu-24.04-x64' && inputs.build_type == 'release'))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are only running these on ubuntu x64 release builds?

Comment thread docs/testing.md
After building, run tests using `ctest` or invoke the binaries directly:
```bash
# Linux/macOS
<build-folder>/bin/<test binaries>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since there are specific examples below do we need the <build-folder>/bin/<test binaries> ?

Comment thread docs/testing.md

Each scenario reports process RSS and thread count at cycle 0, after warmup
cycle 20, and after final cycle 100. Checkpoint sampling waits for the thread
count to remain stable for 500 ms so short-lived teardown work does not cause a

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

// encoder so the scenario can run in CI.
void runRoomServerDeleteCycle(const RoomCredentials& credentials) {
if (std::string_view(credentials.url) != kLocalTestLiveKitUrl) {
throw std::runtime_error("room-server-delete requires LIVEKIT_URL=ws://localhost:7880");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any plan to expand this to remote servers?

delegate.requireDisconnect(livekit::DisconnectReason::ClientInitiated);
}

// Exercises data-track publication, payload enqueueing, explicit unpublication,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these doc strings are great

return output.str();
}

double kibToMib(std::uint64_t kib) { return static_cast<double>(kib) / 1024.0; }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider inline

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for most of these helpers/utils.

Also consider moving to a test_utils or something similar. I get we dont want to depend on actual lib code, but i think we have small converters like this all over tests. If you agree, maybe just make a ticket -- no need to cram in here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants