-
Notifications
You must be signed in to change notification settings - Fork 79
Description
Is there an existing issue for this?
- I have searched the existing issues
Description
I'm using ciborium to serialize data directly into an nng::Message buffer, which implements std::io::Write
. My observation is that this process incurs significant overhead due to frequent reallocations. Specifically, it appears that nng::Message
's underlying buffer management, possibly via its push_back method, reallocates with each small write operation performed by ciborium.
While I can preallocate the nng::Message
's capacity using Message::with_capacity, this requires me to guess the maximum serialization size, leading to potential memory waste or insufficient capacity.
My question is whether ciborium offers a mechanism to predict the exact serialized size of a data structure before the actual serialization occurs. Although I understand such a prediction might not be computationally free, I suspect its cost would be less than alternative approaches, such as serializing into a Vec
(which reallocates in chunks, but still requires a subsequent copy) and then copying the data into the nng::Message
.
Acceptance Criteria
No response
Suggestions for a technical implementation
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status