Repository navigation
Compress Mirror traffic from the Host - #1161
Merged
Merged
Conversation
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.
Summary
Mirror messages were uncompressed. While the iOS app is open, the Host sends the full pane list every 3 seconds: about 40–60 KB per minute (about 3 MB per hour) on the phone's own logs. 096 may carry this traffic through our relays, where every byte costs.
New capability
deflate-v1(docs-ai 097):deflate-v1. A client that sees it sendscompressonce, right after the firstpanes; from then on the Host sends every packet as kind 3: the next part of one raw DEFLATE stream per connection, one message per sync flush. Because the stream keeps its window, a pane list that barely changed costs a few dozen bytes instead of 2.2 KB.Mirror/Shared/MirrorWireCompression.swift.docs/remote-mirror-wire.md, with a vector made by another zlib (Python) for the Android client to check against.Device measurement
iPhone One against one isolated Debug Host with 5 panes, first with the iOS build from
main, then with this build; Host bytes sent, fromnettop:The terminal rendered normally with compression. A chat open was not measured on the device; conversation event JSON compresses 3.7–4× in gzip.
Tests
MirrorWireCompressionTests(Mac): the other zlib's vector; a stream round trip over all payload kinds with repeated lists shrinking; plain payloads pass through without a stream; corrupt, nested and oversized (a 1 MB zero block) payloads are rejected.compressarrives compressed, asking twice is harmless, and a client that never asks gets plain packets.make check,make test,make test-mirror-ios-unit(226): pass.MirrorHost.handlewas split slightly (refresh,writeInput) to stay within the complexity limit; no behavior change.