lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #46290] Optimize passing contiguous buffers to tcp_wri


From: Ambroz Bizjak
Subject: [lwip-devel] [bug #46290] Optimize passing contiguous buffers to tcp_write
Date: Mon, 02 Nov 2015 21:51:28 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36

Follow-up Comment #3, bug #46290 (project lwip):

Hello,

Please consider the general case when the application is sending data out of a
(ring) buffer and cannot assume anything regarding in how large chunks it
receives data into the buffer.

The natural thing for the application to do then is to call tcp_write(no COPY)
for each new chunk of data it gets. It could try to optimize this by waiting a
bit expecting new data, but there's no guarantee about the outcome. The data
really could be arriving slowly in small pieces. If this happens, you using
memory very inefficiently (one pbuf for each chunk of data) and consequently
the throughput is low.

...But the worst part is that you risk exhausting the PBUF pool and
effectively starving other connections (this is why I flagged it as faulty
behavior :). Please note that tcp_write() only checks the queue length limit
when allocating a new segments, and not when appending to the existing last
segment; I do not know if this is intentionally or by mistake.

With this patch, as long as you are sending out of a ring buffer, you know for
a fact that there will be at most one ROM pbuf used per TCP segment, except
for possibly one segment using two due to the ring buffer wrapping. I think it
follows that a connection will use at most TCP_SND_QUEUELEN/2+1 ROM pbufs (/2
due to each segment also having a header pbuf which is also counted into the
TCP_SND_QUEUELEN, but this is a PBUF_RAM pbuf).

I think the extra code is worth the benefit. This feature seems to me like the
equivalent of the OVERSIZE feature but for the no-COPY case, and the logic is
simpler than OVERSIZE.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?46290>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]