Repository navigation
Compress packets from 512 bytes and reuse zlib streams per connection - #199
Merged
Merged
Conversation
Switching an already compressing codec from none to default must start compressing. Fails with the level comparison inverted.
Pins the boundary of "does not get smaller" in deflate_into. Fails with < turned into <= or && turned into ||.
Brings CompDecoder::decode_with from CRAP 11.2 down to 9.2. Full test suite passes unchanged.
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.
With compression on, every outgoing packet of 50 bytes or more is compressed with a new
ZlibEncoder, and every incoming compressed packet is inflated with a newZlibDecoder.This change:
MIN_COMPRESS_LENGTHfrom 50 to 512 bytes. A packet below a few hundred bytes barely shrinks, but each compression costs about 3 µs of setup. The server decides on its own packets with its own threshold, so the result of a small query is still compressed.Compressand oneDecompressin the compressed codec for the life of the connection, reset between packets. The publiccompressandCompDecoder::decodekeep their signatures.PacketCodecencode and decode of one packet, default level, Ryzen 9 7950X3D, one pinned core, median of 5 runs. Decode input is compressed as the server sends it.New codec tests cover round trips around the threshold up to more than one 16 MB chunk on one codec, a level change, small and incompressible packets sent uncompressed, and packets that inflate to another length.
cargo test --features testpasses. Themysql_asyncandmysqllib tests were run withCOMPRESS=1against MySQL 8.0.46, with this branch and with master patched in: same results.