Repository navigation
Add opt-in zstd protocol compression - #1823
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe driver adds optional Zstandard compression through the ChangesOptional Zstandard compression
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Client as MySQL client
participant Driver as MySQL driver
participant Server as MySQL server
participant PacketIO as compIO
participant Codec as Zstandard codec
Client->>Driver: Enable compression and import mysql/zstd
Driver->>Server: Advertise supported compression capability
Server-->>Driver: Negotiate Zstandard or zlib
Driver->>PacketIO: Initialize compression for negotiated capability
PacketIO->>Codec: Encode or decode Zstandard packet payload
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking issue is established by the reviewed changes; normal project checks remain appropriate. Pre-merge checks |
|
There was a problem hiding this comment.
🟢 Approval recommended
The negotiation, bounded decoding, fallback behavior, dependency isolation, documentation, and test coverage are consistent and complete.
0 open findings
What changed in this PR
Adds opt-in Zstandard protocol compression while preserving zlib fallback and dependency isolation.
Changes:
- Adds optional pooled zstd codec and protocol negotiation.
- Documents configuration and dependency behavior.
- Adds codec, negotiation, integration, and CI coverage.
| File | Description |
|---|---|
zstd/zstd.go |
Implements optional zstd codec registration. |
zstd/zstd_test.go |
Tests codec safety and dependency isolation. |
zstd/connection_test.go |
Tests protocol and live-server behavior. |
README.md |
Documents zstd activation and fallback. |
packets.go |
Negotiates zstd and sends its level. |
internal/compression/compression.go |
Defines the optional codec bridge. |
go.sum |
Records dependency checksums. |
go.mod |
Adds the zstd implementation dependency. |
dsn.go |
Updates compression API documentation. |
const.go |
Defines the zstd capability flag. |
connector.go |
Activates negotiated zstd compression. |
compress.go |
Adds zstd packet encoding and decoding. |
compress_negotiation_test.go |
Tests capability negotiation and limits. |
.github/workflows/test.yml |
Runs all packages and live zstd tests. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Thanks for this! Overall the design and implementation look solid to me, and I don't see any blockers. What I like
Design points worth discussing
Minor
CI
|
Since the changes in v1.20 do not provide much benefit for this library, I lowered the dependency version to v1.19.2. In the README, I explained that the dependency on klauspost/compress only occurs when zstd is imported.
In typical cases where compression is effective, calling
added
moved.
added
checked |
Description
Add optional zstd compression via a blank import of
github.com/go-sql-driver/mysql/zstd. Withcompress=true, connections prefer zstd and fall back to zlib when unsupported. Compression uses a fixed level 3.Applications that do not import
mysql/zstddo not compile or linkklauspost/compress.Validated with MySQL 8.4, TLS, MariaDB fallback, and payloads larger than 16 MiB. Added protocol and dependency-isolation tests; race tests and
go vetpass.Checklist