Skip to content

Use protobuf zero-copy deserialisation#51

Open
GnomedDev wants to merge 1 commit intob-r-u:mainfrom
GnomedDev:zero-copy
Open

Use protobuf zero-copy deserialisation#51
GnomedDev wants to merge 1 commit intob-r-u:mainfrom
GnomedDev:zero-copy

Conversation

@GnomedDev
Copy link
Copy Markdown

This enables the with-bytes feature of protobuf, and enables it via protobuf-codegen, in order to reduce allocations and memory copying by using the Bytes library. This means that when possible string and bytes fields in the protobuf are referring to the original protobuf data, instead of making many small allocations for each piece of data.

The upsides are:

  • Improved runtime performance, due to less heap allocations and memory copying.

The downsides of this are:

  • Slightly increased complexity when using the library, as the user has to learn how to use Bytes and protobuf::Chars.
  • Possible increased average memory usage, as cloning a single element from the stringtable will keep the entire block alive.

I have measured a 5-10% performance uplift with the included benchmark, but my machine (overheating laptop) is not super reliable so benchmarking should be done on a stable machine.

@chingiztob
Copy link
Copy Markdown

Hi, is this merge planned, @b-r-u @GnomedDev ?

@GnomedDev
Copy link
Copy Markdown
Author

I have not heard anything from the maintainer, but I am absolutely good with this merging as-is, as long as someone can measure it as an actual improvement.

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.

2 participants