Re:Fivefold Slower Compared to Go? Optimizing Rust's Protobu...
by v0y4g3r on Friday April 12, 2024 @04:29AM
(#40010495)
FlatBuffers does the trick as a better replacement to ProtoBuf when running in some resource-critical devices. We were working on a project that leverage Arrow IPC (internally FlatBuffers) and shared memory to collect metrics on edge devices with limit CPU and memory, hopefully we can open source it soon.
But in this case the format is defined by [Prometheus](https://github.com/prometheus/prometheus/blob/main/prompb/re...) and we just adopt that.
It's interesting that the protobuf code generator for Go seems to allow this direct access. For C++, you also need a copy (and potentially a heap allocation) since `string` fields are returned via `const std::string&`. Protobuf support for `std::string_view` has been years in the making.
Maybe just switch to FlatBuffers?