Repository navigation
Conversation
FfiClient initializes the FFI server with captureLogs set to true, as it has since the initial commit, but no code in this SDK handles the `logs` FFI event. In capture mode the Rust logger forwards every record down to trace level, libwebrtc's dump of each data channel packet included, so a process decoded and dispatched thousands of unused events per second, and each one reached every Room's onFfiEvent and its lock. With capture off the native logger falls back to env_logger, so RUST_LOG controls the native logs again.
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.
FfiClientinitializes the FFI server withcaptureLogsset totrue, as it has since the initial commit, but nothing in this SDK handles thelogsFFI event. In capture mode the RustFfiLoggeraccepts every record down to trace level (enabled()returnstrueand the max level isTrace), so every native log, including libwebrtc'stext_pcap_packet_observerdump of each data channel packet, crosses into JavaScript, is decoded withFfiEvent.fromBinaryand is emitted to everyffi_eventlistener, only to be discarded.RUST_LOGhas no effect while capture is on.In a process that holds several rooms, each of those events also reaches every
Room.onFfiEvent, which takes itsffiEventLockbefore discarding it, so the cost grows with the number of rooms times the traffic of all of them.With capture off, the native logger falls back to
env_logger, soRUST_LOGcontrols the native logs again (errors only when it is unset).Measurements
Against a local LiveKit server, one process holding N hidden, subscribe-only agent rooms (
autoSubscribe: false), while another process joins and leaves 2 participants per room in two rounds. Node 24,NODE_ENV=production.Log records forwarded to JavaScript in 17 s with 10 rooms:
logsevent each)@livekit/rtc-node1.2.3libwebrtcProcess holding 100 rooms:
connect()@livekit/rtc-node1.2.3With 25 and 50 rooms this branch stays at 6% CPU and 11 ms p99, while 1.2.3 goes from 15 ms to 32 ms p99 as the rooms double.
Notes
RUST_LOGunset, libwebrtc now printsERROR libwebrtc] (cuda_context.cpp:86): Failed to initialize CUDA.to stderr on hosts without a GPU. It was emitted before as well and dropped in JavaScript.lk-rtclogger is ever wanted, the Rust side would also have to filter by level in capture mode; otherwise every trace record keeps crossing the boundary.Script that counts the forwarded logs