Open rotty opened 7 years ago
Zero-copy is nice, but we have to consider the implications of callbacks from C - e.g. when the callback panics.
Yes, this a hairy subject to be approached with care and careful study of the nomicon.
Even without specialization, we could provide an efficient implementation of
From<Vec<u8>>
forMessage
, i.e. one that moves data out of the vector and hands ownership over to zmq.
This would be really nice, for example for serializing Protobuf objects into ZeroMQ messages.
See http://zeromq.org/blog:zero-copy. This may also make the
Sendable
trait and wrappingzmq_send_const
(see #119) unnecessary, as it should be possible to provide more efficient implementations ofInto<Message>
for&'static [u8]
. Even without specialization, we could provide an efficient implementation ofFrom<Vec<u8>>
forMessage
, i.e. one that moves data out of the vector and hands ownership over to zmq.Before implementing this, it would be nice to add a basic micro-benchmark first as a baseline. Even better would be to transcribe a (hopefully) existing micro-benchmark employing "zero-copy", so Rust performance can be compared to C before and after implementing the optimization.