redis icon indicating copy to clipboard operation
redis copied to clipboard

Allocate only once for the request notifier and multiplexer::elem

Open mzimbres opened this issue 1 month ago • 2 comments

We currently perform one dynamic allocation for the notifier and one for the multiplexer::elem https://github.com/boostorg/redis/blob/00f3ec9b78454211c7b8d461b11411c8b1ef1ad3/include/boost/redis/connection.hpp#L193-L194

It looks like it is possible to put these two data structures into a single struct and allocate only once. As part of the ticket we should also cache these structs to achieve asymptotically zero allocations.

PS1: Do we need to allocate multiplexer::elem dynamically at all? These structs are not that big and it looks like they can be also copied. Btw, are there any lower overhead alternatives to shared_ptr for single-threaded use?

PS2: Is there any alternative to std::function with better small buffer optimization? Most adapters are pretty small data structures.

mzimbres avatar Nov 19 '25 10:11 mzimbres