[nanomsg] Re: why memcpy data to be sent?

  • From: Martin Sustrik <sustrik@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Tue, 28 Oct 2014 07:44:13 +0100

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Zero copy is done via nn_allocmsg():

          void *buf = nn_allocmsg (12, 0);
           memcpy (buf, "Hello world!", 12);
           nn_send (s, &buf, NN_MSG, 0);

Martin

On 28/10/14 07:19, zerotacg wrote:
> I did not dig into nn_msg_init_chunk but the docu [1] hints that
> they implement zero-copy. Did you consider using a non scattered
> array to get into what looks like the zero-copy case [2] ?
> 
> 
> Zero-Copy
> 
> While ZeroMQ offers a "zero-copy" API, it's not true zero-copy.
> Rather it's "zero-copy till the message gets to the kernel
> boundary". From that point on data is copied as with standard TCP.
> nanomsg, on the other hand, aims at supporting true zero-copy
> mechanisms such as RDMA (CPU bypass, direct memory-to-memory
> copying) and shmem (transfer of data between processes on the same
> box by using shared memory). The API entry points for zero-copy
> messaging are nn_allocmsg and nn_freemsg functions in combination
> with NN_MSG option passed to send/recv functions.
> 
> [1] http://nanomsg.org/documentation-zeromq.html [2]
> https://github.com/nanomsg/nanomsg/blob/master/src/core/global.c#L708
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJUTzs9AAoJENTpVjxCNN9YTb4H/jYXrqWjDpQQy0W6lYJKXyRa
j2wkuByYsZnVcbGTDwW5UklJwaBwjmkrzL2MW+fdZNFHGeF9adYGRkLomybL7Q5O
xWZ2VX96/OqxKUWMPthEPg89OfiM2gYVj3ASU1qTXuQw6KKI5+9ROX7CWhbl8x/M
mKUhksaLDu0IA+CaJUTD3i1hTz/mwJ7DDyYt5crDuMiAJ+qVyjI16pDmLmavtzct
SeD9QTKO0ReHL8+pQRaeXHpNai1U0wUuefj7PRHjQZFq0MSHQ4+GR/GBHgwFKxOm
pRS51Q8MilZMY5ELKOEU8/rhBS6bRfFN5fm65EZvO9xbFtF8aW9UZt5XhSiLs1o=
=zqYy
-----END PGP SIGNATURE-----

Other related posts: