[nanomsg] Re: nn_recv with padding

  • From: Martin Sustrik <sustrik@xxxxxxxxxx>
  • To: Garrett D'Amore <garrett@xxxxxxxxxx>, nanomsg@xxxxxxxxxxxxx
  • Date: Tue, 13 May 2014 07:18:24 +0200

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

On 13/05/14 07:23, Garrett D'Amore wrote:

> Are people using such large (>100kB) messages with nanomsg?  I’ve
> always assumed that zero copy was a false savings but maybe because
> I figure that the largest useful message I’d ever want send is at
> most a few pages (10k or so).

Yes, there are users with large messages. Once you get to the
megabytes range, zero-copy can actually make a difference. Now I
recall we've measured that once:

Here's the relevant table with message sizes (A), latency with copying
(B) and latency without copying (C):

(A)     (B)             (C)
4 kB    45.856 us       45.471 us
8 kB    55.690 us       57.462 us
16 kB   81.309 us       79.635 us
32 kB   99.423 us       97.009 us
64 kB   164.521 us      152.227 us
128 kB  227.577 us      192.544 us
256 kB  371.325 us      307.026 us
512 kB  682.949 us      528.641 us
1 MB    1464.738 us     1125.205 us
2 MB    2697.648 us     2085.429 us
4 MB    5045.856 us     3714.495 us
8 MB    9662.857 us     7199.121 us
16 MB   20898.646 us    13861.691 us
32 MB   44297.914 us    27565.414 us
64 MB   87754.242 us    54715.375 us
128 MB  167838.859 us   108787.906 us
256 MB  327360.406 us   216642.000 us

> That said, mangos has an optimization where the header space is 
> allocated in such a way that attempts to avoid having to realloc or
> move a message when we want to add additional header content.   But
> I’m using go byte slices for it.  Sadly, go doesn’t have a nice way
> for me to preallocate “headroom” like we do with NIC packet buffers
> in the kernel.

Time to patch go? :)

Martin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTcasfAAoJENTpVjxCNN9Y3pUH/inGTs7OTV0emGZn3+OMANtj
6/C3HIrabdDG7l/L5rtN4qEdXgZGWrIZlW/H9v0kKlNqaEt1Us4owa4LZocsWnv2
SwkiNXm6lgsCWwoqpfh++FfkRa0Kqu/FQrXOp88bdSeWdR/5RJ5PvDsePIgJ6Oob
gbGH2wAFA+/LLJtGfzkQUvXDmcq/fHbKsmkpa5e23RRmFZ0oSd21PvNxsazlI7Z2
QFNY9HPhPnqQjvG2XJPkeVOsoAd/sTz6jd+tyK9VA4XB3z3sNjY3JuUDjS3fbffi
GJZQACLY2/k0G5w5wE7cPWvP+FOPLq5vU0ZsP96hAe7JhG+kai5p+IZDdWDhBOc=
=b5cI
-----END PGP SIGNATURE-----

Other related posts: