4 ms·
> In Go, a string is just a simple wrapper around []byte, and deserializing a string field can be done by simply assigning the original buffer's pointer and len
by secondcoming 3y ago
> In Go, a string is just a simple wrapper around []byte, and deserializing a string field can be done by simply assigning the original buffer's pointer and length to the string field. However, Rust's PROST, when deserializing String type fields, needs to copy the data from the original buffer into the String
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?
- v0y4g3r 3y agoFlatBuffers 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/remote.proto#L22-L28 https://github.com/prometheus/prometheus/blob/main/prompb/re...) and we just adopt that.