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

[Feature Request] Binary websocket traffic #341

Open
Gelbpunkt opened this issue Aug 16, 2020 · 4 comments
Open

[Feature Request] Binary websocket traffic #341

Gelbpunkt opened this issue Aug 16, 2020 · 4 comments

Comments

@Gelbpunkt
Copy link

Hi,

my personal usecase is that I want to encode JSON more efficiently in Python to send it over the websocket and one of the best ways is to use alternate JSON encoders like orjson which encode to bytes instead of strings. Decoding those to strings before sending them over the websocket connection feels like an unnecessary overhead.

Current, Lavalink rejects any binary websocket traffic, so I am wondering if it would be possible to add support for it. From what I've experienced in languages such as Rust or Python, JSON decoding from bytes can also be more efficient than from strings, so it might be a beneficial addition on both sides. Either way I imagine this to be easy to implement and one of the small things that can make a nice difference.

@freyacodes
Copy link
Member

This is difficult to implement with the library we are currently using. I'm not aware of a JVM library that takes both JSON and BSON.

The performance overhead is likely negligible.

@DRSchlaubi
Copy link
Contributor

This is difficult to implement with the library we are currently using. I'm not aware of a JVM library that takes both JSON and BSON.

The performance overhead is likely negligible.

it should be possible with kotlinx.serialization, so this might be possible with not that much effort

@JellyBrick
Copy link

JellyBrick commented Mar 7, 2023

This is difficult to implement with the library we are currently using. I'm not aware of a JVM library that takes both JSON and BSON.

The performance overhead is likely negligible.

it should be possible with kotlinx.serialization, so this might be possible with not that much effort

In addition to the methods described above, this feature can be implement by using https://github.com/FasterXML/jackson-datatypes-misc in the current implementation. (without major code refactoring)

Additional comment: BSON is inefficient compared to other binary data format.
Sometimes BSON takes longer to parse than JSON.

@freyacodes
Copy link
Member

I am still not convinced that this is an optimization that is worth bothering with. The transmission of WebSocket events is magnitudes smaller than all the other network traffic that Lavalink does

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

No branches or pull requests

5 participants