Paul Colomiets wrote: > Hi Alex, > > On Wed, Oct 29, 2014 at 12:52 PM, Alex Elsayed > <eternaleye@xxxxxxxxx> wrote: >> The points people have been bringing up against it - zero-copy not being >> worth it under 512K, etc - are mostly from the >> crossing-protection-domains type. >> > > So do you suggest that zero-copy between _layers_ make sense on larger > or smaller messages? > Ownership transfer between layers can have basically no runtime overhead, since you can enforce it at the language level (C++ unique_pointer<T>, Rust ...basically everything except &references); thus it can be beneficial for any message smaller than a pointer. With inlining, it can be _actually_ free, since you don't even need to marshal the pointer into function arguments. However, the downsides mostly manifest in languages like C, where there isn't One True Language-Blessed Destructor Protocol. Because without that, the fact that ownership transfer also transfers the responsibility to free memory becomes a liability, and requires additional APIs like a custom free callback.