Task #1293
open
Reserve buffer space when receiving packets on all faces
Added by Alex Afanasyev over 10 years ago.
Updated about 10 years ago.
Description
When receiving packets on all faces, we need to reserve some space in front and at the back of the packet. This will reduce number of copy operations (ideally to just first initial copy).
Please explain:
- What scenarios would need copying ?
- Why reserving buffer space can reduce copying?
- How to calculate how much buffer space should be reserved?
One example is the TX path of EthernetFace. When the ethernet packet is constructed, the link layer header must be prepended to the serialized TLV, and in some cases padding must be added after it. If the buffer already has some headroom and tailroom, that space can be filled with the aforementioned data, thus saving a memory allocation and a copy operation.
The ethernet header size is fixed (14 bytes), so the headroom could just be static.
The tailroom must be at least max(0, ethernet::MIN_DATA_LEN - data.size())
in the ethernet case.
An skbuff-like mechanism or scatter/gather would solve this nicely.
I think I created this issue before I discovered scatter/gather capability in boost.asio.
EthernetFace does not use boost to send and receive packets...
- Target version deleted (
v0.2)
20140514 meeting decides to defer this performance optimization.
Alex or Davide should write more about what's the problem.
20141114 conference call urges Alex to complete the definition of this problem.
Also available in: Atom
PDF