Skip to content

Support opt-in psrpc bus compression - #488

Merged
paulwe merged 1 commit into
mainfrom
psrpc-bus-compression
Sep 6, 2026
Merged

paulwe merged 1 commit into
mainfrom
psrpc-bus-compression

Conversation

@paulwe

@paulwe paulwe commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

psrpc v0.7.6 (psrpc#130) added opt-in gzip at the bus boundary, and protocol#1771 surfaced it as rpc.PSRPCConfig.Compression with a BusOptions() conversion. runService built the bus from the redis client alone, so there was no way to reach the setting.

psrpc:
  compression:
    quality: 6
    threshold: 1024
    max_decompressed_size: 0

Shape

Ingress carried no rpc.PSRPCConfig at all, only a top-level psrpc_skip_claim bool, so this adds the whole block under a psrpc: key. That matches the layout livekit-server uses (livekit#4844) and gives egress and SIP a shape to copy — neither has done this yet.

It is seeded in NewConfig rather than InitDefaults, because the handler subprocess parses its config with initialize=false. Without the seed, a config setting only quality would leave Threshold at zero and compress every payload, however small.

The service process holds the only bus. The per-session handler subprocess talks to the parent over unix-socket gRPC IPC and never builds one, so nothing else needed threading. The integration suite bypasses NewConfig, so GetDefaultConfig carries the same seed.

Compression is off by default

A peer on psrpc older than v0.7.6 ignores the compression marker — psrpc deserializes with DiscardUnknown — and then decodes the gzipped bytes as the payload, so the message is dropped without an error. livekit-server, egress, SIP and agent workers share this bus, so enabling it is a two-stage operator action: roll v0.7.6+ everywhere, then raise quality at the publishers. The README says so at the setting.

max_decompressed_size only affects reading, so it can be set ahead of quality.

Testing

pkg/config/config_test.go is new; the package had no tests. It covers the defaults and an override that leaves Threshold at its default.

Verified the config actually reaches the compressor with a throwaway psrpc echo RPC over a local bus: the default config round-trips, quality: 6 with threshold: 1 round-trips, and adding max_decompressed_size: 64 drops that same 16 KB payload — which is what proves it was gzipped rather than skipped by the threshold. quality: 0 with the same cap delivers it.

Not verified against a live livekit-server; that needs a peer already on psrpc v0.7.6+.

Note on the protocol pin

v1.51.1-0.20260905133529-a4f4b5c0c23f is protocol main at the #1771 merge, the same pseudo-version livekit#4844 uses. It is 14 commits ahead of the previous pin and otherwise additive.

@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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

psrpc v0.7.6 (psrpc#130) added opt-in gzip at the bus boundary, and
protocol#1771 surfaced it as rpc.PSRPCConfig.Compression with a
BusOptions() conversion. runService built the bus from the redis client
alone, so there was no way to reach the setting.

Ingress carried no rpc.PSRPCConfig at all, only a top-level
psrpc_skip_claim bool, so add the whole block under a psrpc: key. That
matches the layout livekit-server uses (livekit#4844) and gives egress
and SIP a shape to copy. It is seeded in NewConfig rather than
InitDefaults because the handler subprocess parses its config with
initialize=false; without the seed, a config setting only quality would
leave Threshold at zero and compress every payload, however small.

The service process holds the only bus. The per-session handler
subprocess talks to the parent over unix-socket gRPC IPC and never
builds one, so nothing else needed threading. The integration suite
bypasses NewConfig, so GetDefaultConfig carries the same seed.

Compression is off by default. A peer on psrpc older than v0.7.6 ignores
the compression marker -- psrpc deserializes with DiscardUnknown -- and
then decodes the gzipped bytes as the payload, so the message is dropped
without an error. livekit-server, egress, SIP and agent workers share
this bus, so enabling it is a two-stage operator action: roll v0.7.6+
everywhere, then raise quality at the publishers. The README says so at
the setting. max_decompressed_size only affects reading, so it can be
set ahead of quality.

pkg/config/config_test.go is new; the package had no tests. It covers
the defaults and an override that leaves Threshold at its default.

Verified the config actually reaches the compressor with a throwaway
psrpc echo RPC over a local bus: the default config round-trips, quality
6 with threshold 1 round-trips, and adding max_decompressed_size 64
drops that same 16 KB payload -- which is what proves it was gzipped
rather than skipped by the threshold. quality 0 with the cap delivers
it. Not verified against a live livekit-server; that needs a peer
already on psrpc v0.7.6+.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@paulwe
paulwe force-pushed the psrpc-bus-compression branch from 7d7edc3 to b83a018 Compare September 6, 2026 15:59
@paulwe
paulwe merged commit 7a03742 into main Sep 6, 2026
7 checks passed
@paulwe
paulwe deleted the psrpc-bus-compression branch September 6, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants