Warning
This post was published 31 days ago. The information described in this article may have changed.
I have a server application that needs to serialize messages into slices of bytes of different lengths, and periodically retry sending those messages until they either expire or are acknowledged. I've identified this area of my code as a performance bottleneck and am looking for ways to improve beyond having a global allocation for each message slice.
These messages are serialized once and then enqueued to be sent to multiple clients, though not every client gets every message. Ideally each client's representation on the server would have a VecDeque
containing a collection of Rc
s or some sort of refcounted representations to a serialized message (a [u8]
of variable length) that is waiting to be (re)sent.
My first pass sketch of a data structure for this would be:
[u8]
page/chunk to push messages to as subslicesRc
or Rc
-like handle to that subslice of the chunk
With that in mind, some questions:
Rc
? I found this thread about creating subslices. Can an Rc
also be changed to have custom drop behavior (e.g. returning the chunk to a free list rather than truly dropping it)?3 posts - 2 participants
🏷️ rust_feed