Skip to content

[Bugfix] Serve requests compressed with deflate - #163

Merged
theminjunchoi merged 2 commits into
mainfrom
fix/deflate-requests
Nov 20, 2026
Merged

theminjunchoi merged 2 commits into
mainfrom
fix/deflate-requests

Conversation

@theminjunchoi

@theminjunchoi theminjunchoi commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:

Fixes #155

Requests compressed with deflate always failed with UNIMPLEMENTED, so a grpcio client with deflate turned on couldn't make any call. grpcio serves these fine.

This enables tonic's deflate feature and accepts deflate alongside gzip. Responses are still sent uncompressed.

gRPC's deflate is really the zlib format. tonic decodes it with ZlibDecoder, so it matches what grpc-core sends.

How it was tested:

  • The gzip test now runs with deflate too. The deflate case fails on main.
  • With the issue's script, deflate now returns OK for unary and server-streaming calls, same as grpcio. Gzip and uncompressed calls behave as before.
  • pytest tests: 306 passed, 1 skipped. Clippy, rustfmt and ruff are clean.
  • A downstream project's gRPC tests (178, on NativeGrpcFront) pass with this wheel.
  • Uncompressed calls are as fast as before: 64 B unary, 10 runs each alternating with main, on both NativeGrpcFront and server().
  • The wheel grows by 2.7 KB, since flate2 was already pulled in for gzip.

If applicable:

  • this PR changes user-facing behavior, and the docs are updated
  • this PR contains tests

Signed-off-by: MinJun Choi <mj04300017@gmail.com>
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Perf: server cost per call

Head 618d295 against base fdbad8d, 10 rounds in random order on one runner (4 CPUs, grpcio 1.85.1). Run

Scenario Metric Base Head Change Head worse Verdict
low-level unary CPU µs/call 46.67 46.67 +0.0% 3/10 no change
low-level unary context switches/call 1.46 1.48 +0.4% 6/10 no change
server() unary CPU µs/call 87.50 86.67 -0.5% 4/10 no change
server() unary context switches/call 2.86 2.87 +0.3% 6/10 no change
aio.server() unary CPU µs/call 68.33 69.17 +0.0% 4/10 no change
aio.server() unary context switches/call 1.38 1.37 +0.3% 5/10 no change
server() stream CPU µs/call 216.67 216.67 +0.0% 4/10 no change
server() stream context switches/call 7.80 7.73 -0.9% 2/10 no change
aio.server() stream CPU µs/call 208.33 208.33 +1.0% 5/10 no change
aio.server() stream context switches/call 3.95 3.96 +0.6% 6/10 no change

Signed-off-by: MinJun Choi <mj04300017@gmail.com>
@theminjunchoi
theminjunchoi merged commit 8d0547f into main Nov 20, 2026
10 checks passed
@theminjunchoi
theminjunchoi deleted the fix/deflate-requests branch November 20, 2026 00:30
@theminjunchoi theminjunchoi mentioned this pull request Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deflate-compressed requests are rejected with UNIMPLEMENTED

1 participant