Skip to content

Conversation

@tank-500m
Copy link

What?

Enable client-side gRPC request compression in k6.
Support opt-in codecs: gzip, zstd, and snappy.

Why?

Bandwidth & cost savings: large protobuf messages and high RPS scenarios benefit from request compression.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

@tank-500m tank-500m requested a review from a team as a code owner August 29, 2025 02:23
@tank-500m tank-500m requested review from AgnesToulet and ankur22 and removed request for a team August 29, 2025 02:23
@CLAassistant
Copy link

CLAassistant commented Aug 29, 2025

CLA assistant check
All committers have signed the CLA.

@ankur22
Copy link
Contributor

ankur22 commented Aug 29, 2025

Thanks @tank-500m for the PR! We are taking a look and considering our options. We're a little unsure about the additional dependencies that are being added, and we need to think about how the new option impacts the overall API, and whether we have something else within k6 that does something similar already (enabling compression). We will get back to you with next steps soon.

Copy link
Contributor

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tank-500m,

Thanks for your contribution and patience while we discuss this internally.

We've happy to move forward with this PR since it does indeed look like it is useful and it doesn't impact any planned future work.

What we're still a little unsure of are the dependencies that are being added. The dependency that we would like you to reconsider is:

  • github.com/mostynb/go-grpc-compression v1.2.3

Is there a way to avoid having to add anything new to repo and still have GRPC compression?

@tank-500m
Copy link
Author

tank-500m commented Sep 8, 2025

@ankur22
Thanks for the thoughtful review!

If we drop mostynb/go-grpc-compression, we’ll need to add a small amount of internal code to support custom compressors, because grpc.WithDefaultCallOptions(grpc.UseCompressor("...")) only works for names that have been registered with gRPC’s encoding registry. The third-party package was just a thin adapter that registers zstd/snappy for us.

If remove mostynb/go-grpc-compression, the new direction is this:
zstd: use github.com/klauspost/compress/zstd to implement a tiny encoding.Compressor adapter (registering name zstd). It’s a well-maintained, battle-tested codec.

snappy (optional): similarly, we can wire up github.com/golang/snappy.

gzip: continues to use the built-in gRPC gzip support.

This keeps the external surface area small while still giving users a practical compression choice (zstd is the main ask for high-throughput gRPC). Let me know if you prefer zstd-only to start; I can push an update that adds an internal zstd compressor + registry and removes the mostynb dependency.

@ankur22
Copy link
Contributor

ankur22 commented Sep 11, 2025

Let me know if you prefer zstd-only to start; I can push an update that adds an internal zstd compressor + registry and removes the mostynb dependency.

@tank-500m I think this is a good step forward. If you could implement the changes to allow for this single compression (zstd) without adding any external dependencies, please 🙇

@tank-500m
Copy link
Author

@ankur22
Sorry for the delay here.
Per the review feedback about extra deps, I’ve removed mostynb/go-grpc-compression and switched to an in-tree compressor that uses github.com/klauspost/compress/zstd. The compressor is registered via gRPC’s encoding registry so grpc.UseCompressor("zstd") works without third-party adapters.

@codebien codebien requested a review from ankur22 October 9, 2025 13:21
@tank-500m tank-500m temporarily deployed to azure-trusted-signing October 16, 2025 13:32 — with GitHub Actions Inactive
@tank-500m tank-500m temporarily deployed to azure-trusted-signing October 16, 2025 13:36 — with GitHub Actions Inactive
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.

3 participants