Repository navigation
Conversation
The SSE replay buffer RPUSHes every streamed event to a per-run Redis List, including full "values" state snapshots, unslimmed and capped only by count (10k) and TTL (600s). On a large graph state that List is the dominant broker-memory consumer. Gzip entries over 1 KiB before storing them (base64-wrapped, since the client runs decode_responses=True), typically shrinking that JSON several-fold. Off by default (REDIS_REPLAY_COMPRESSION). Entries are self-describing via a "gz:" marker, so a reader decodes both formats regardless of the flag — deploy everywhere first, then flip the flag on. Only the stored List is compressed; the transient PUBLISH payload is untouched. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ChrisXuzhou
marked this pull request as ready for review
September 17, 2026 00:17
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.
:claude:
What
Opt-in gzip compression for the SSE replay buffer (the per-run Redis List in
redis_broker.py).REDIS_REPLAY_COMPRESSION(default false).gz:+ base64(gzip(json)). Below the threshold, or when off, entries stay plain JSON._decompressdecodes an entry by itsgz:marker, not the flag, so a reader on this version handles both compressed and plain entries.PUBLISHpayload is left plain (transient, no memory cost).Why
The replay buffer RPUSHes every streamed event — including full
valuesstate snapshots (the default stream mode) — unslimmed, capped only by count (10k) and TTL (600s). On a large graph state it's the dominant Redis-memory consumer. That JSON compresses several-fold, so this is the biggest single lever on broker memory.Rollout (order matters)
Older instances can't decode
gz:entries, so this must roll out reads-before-writes:REDIS_REPLAY_COMPRESSION=trueto start writing compressed.Merging with the default keeps it a no-op, so it's safe to land ahead of the flip.
Tests
Added
TestReplayCompressionintest_redis_broker.py: round-trip + genuine shrink, disabled/below-threshold passthrough, plain-JSON passthrough (the back-compat guarantee),replay()decoding compressed entries, andput()compressing the stored entry while leavingPUBLISHplain.make test-apigreen (54 passed, incl. all pre-existing), ruff clean.🤖 Generated with Claude Code