Repository navigation
perf(ffi): filter discarded Python logs before forwarding - #1647
Draft
theomonnom wants to merge 1 commit into
Draft
theomonnom wants to merge 1 commit into
theomonnom wants to merge 1 commit into
Conversation
Contributor
Changeset ✓This PR includes a changeset covering all affected packages:
|
This was referenced Nov 8, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR: Skip native log records that Python would discard before paying their allocation, serialization, and forwarding costs.
FFI/protobuf scope: This removes some discarded logging work before serialization and the Python callback. It does not change the audio protobuf protocol, and the experiment does not isolate protobuf's CPU cost.
Python currently discards some native log records after Rust has allocated, serialized, and forwarded them. Apply the same policy in the native logger before that work when the FFI client identifies itself as Python.
TRACE remains discarded. DEBUG from
libwebrtcand targets beginning withlivekitis forwarded only whenLIVEKIT_RTC_DEBUGistrueor1, with the same whitespace/case handling as Python. The environment is read dynamically. INFO/WARN/ERROR, other DEBUG targets, other SDKs, and the uncaptured env_logger path keep their existing behavior.Validation: the Rust policy test passed for target/severity/debug combinations; cargo formatting and patch checks passed. Two controlled AgentSession trials also passed receive/loop/playout/interrupt gates. Both cohorts used the same native binary and Python callback; the early-filter flag was changed only after joining so connection metadata was identical.
The isolated CPU result is inconclusive: paired changes were +1.31% and -0.58% (mean 0.35%). No reliable session-capacity gain is claimed. Keep this optional and review it independently from the receive and Opus changes. The policy mirrors the current Python implementation and should be kept synchronized if that policy changes.
Related draft PRs: receive batching, Opus AVX2, inline VAD, RTC regression tests.