tychedelia / kafka-protocol-rs

Rust Kafka protocol
Apache License 2.0
58 stars 22 forks source link

Zero copy message decoding #42

Open thedodd opened 8 months ago

thedodd commented 8 months ago

This would add a next level of performance to parsing incoming Kafka requests. The main idea:

Other projects which have explored this space:

One thing that could help bypass a lot of the difficulty with alignment and the like: just use accessors to access data. Don't attempt to build structs which are backed by the buffer. Instead, access fields of data via methods on a struct which simply embeds the Bytes buffer. Definitely still edge cases and things to work through; however, that alone will bypass a large portion of alignment issues.

Thoughts?

tychedelia commented 8 months ago

At one point, I was working on a proxy that could benefit from this approach, but ultimately decided I just needed to parse the header which is pretty straight forward. I'd be curious to know how much overhead we currently have parsing and constructing messages. And what the use cases of our users are and whether they'd benefit from such an API. I think I'd want such a project to be driven by a production user to make sure any improvements were worth the complexity cost.