Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(websocket): remove deflate compression option #3949

Merged
merged 6 commits into from
May 16, 2023

Conversation

thomaseizinger
Copy link
Contributor

Description

This option is the only reason we pull in a dependency on the shared zlib library. Unfortunately, we cannot use a pure Rust backend here because that one does not support configuring the window bits of the deflate algorithm which is used in the deflate websocket extension.

Using websockets in libp2p is already crazy inefficient because you end up with double encryption when using /wss (which is enforced by browsers if your website is served via https). A good encryption algorithm like noise or TLS produces an output that looks completely random. Any attempt in compressing this is pretty much wasted CPU power.

Thus, I think removing this configuration option does not really hurt and allows us to remove the dependency on the zlib shared library.

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Good thinking.

Missing a changelog entry.

@mergify mergify bot merged commit fbd471c into master May 16, 2023
@mergify mergify bot deleted the feat/remove-compression-websocket branch May 16, 2023 09:40
@folex
Copy link
Contributor

folex commented Jul 13, 2023

What's the alternative way to enable compression for a protocol? Or should it be done on a per-protocol level manually?

@thomaseizinger
Copy link
Contributor Author

What's the alternative way to enable compression for a protocol? Or should it be done on a per-protocol level manually?

You are better off compressing the data before writing it to the stream or generally use a more space-efficient encoding / data format.

Compressing encrypted data makes little sense so you can't apply it generically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants