2019-11-06 10:58:28 -08:00
|
|
|
.. _scalar_vector:
|
2018-07-26 12:45:10 -04:00
|
|
|
|
2019-11-06 10:58:28 -08:00
|
|
|
==================================
|
|
|
|
Scalar vs Vector packet processing
|
|
|
|
==================================
|
2018-07-26 12:45:10 -04:00
|
|
|
|
2019-11-06 10:58:28 -08:00
|
|
|
FD.io VPP is developed using vector packet processing, as opposed to
|
|
|
|
scalar packet processing.
|
2018-07-26 12:45:10 -04:00
|
|
|
|
2019-11-06 10:58:28 -08:00
|
|
|
Vector packet processing is a common approach among high performance packet
|
|
|
|
processing applications such FD.io VPP and `DPDK <https://en.wikipedia.org/wiki/Data_Plane_Development_Kit>`_.
|
|
|
|
The scalar based approach tends to be favoured by network stacks that
|
|
|
|
don't necessarily have strict performance requirements.
|
2018-07-26 12:45:10 -04:00
|
|
|
|
|
|
|
**Scalar Packet Processing**
|
|
|
|
|
|
|
|
A scalar packet processing network stack typically processes one packet at a
|
|
|
|
time: an interrupt handling function takes a single packet from a Network
|
2019-10-27 17:28:10 -04:00
|
|
|
Interface, and processes it through a set of functions: fooA calls fooB calls
|
2018-07-26 12:45:10 -04:00
|
|
|
fooC and so on.
|
|
|
|
|
2021-08-19 11:38:06 +02:00
|
|
|
.. code-block:: none
|
2018-07-26 12:45:10 -04:00
|
|
|
|
|
|
|
+---> fooA(packet1) +---> fooB(packet1) +---> fooC(packet1)
|
|
|
|
+---> fooA(packet2) +---> fooB(packet2) +---> fooC(packet2)
|
|
|
|
...
|
|
|
|
+---> fooA(packet3) +---> fooB(packet3) +---> fooC(packet3)
|
|
|
|
|
|
|
|
|
2019-10-27 17:28:10 -04:00
|
|
|
Scalar packet processing is simple, but inefficient in these ways:
|
2018-07-26 12:45:10 -04:00
|
|
|
|
|
|
|
* When the code path length exceeds the size of the Microprocessor's instruction
|
|
|
|
cache (I-cache), `thrashing
|
|
|
|
<https://en.wikipedia.org/wiki/Thrashing_(computer_science)>`_ occurs as the
|
|
|
|
Microprocessor is continually loading new instructions. In this model, each
|
|
|
|
packet incurs an identical set of I-cache misses.
|
|
|
|
* The associated deep call stack will also add load-store-unit pressure as
|
|
|
|
stack-locals fall out of the Microprocessor's Layer 1 Data Cache (D-cache).
|
|
|
|
|
|
|
|
**Vector Packet Processing**
|
|
|
|
|
|
|
|
In contrast, a vector packet processing network stack processes multiple packets
|
|
|
|
at a time, called 'vectors of packets' or simply a 'vector'. An interrupt
|
2019-10-27 17:28:10 -04:00
|
|
|
handling function takes the vector of packets from a Network Interface, and
|
2018-07-26 12:45:10 -04:00
|
|
|
processes the vector through a set of functions: fooA calls fooB calls fooC and
|
|
|
|
so on.
|
|
|
|
|
2021-08-19 11:38:06 +02:00
|
|
|
.. code-block:: none
|
2018-07-26 12:45:10 -04:00
|
|
|
|
|
|
|
+---> fooA([packet1, +---> fooB([packet1, +---> fooC([packet1, +--->
|
|
|
|
packet2, packet2, packet2,
|
|
|
|
... ... ...
|
|
|
|
packet256]) packet256]) packet256])
|
|
|
|
|
2021-08-19 11:38:06 +02:00
|
|
|
This approach fixes:
|
2018-07-26 12:45:10 -04:00
|
|
|
|
2019-10-27 17:28:10 -04:00
|
|
|
* The I-cache thrashing problem described above, by amortizing the cost of
|
2018-07-26 12:45:10 -04:00
|
|
|
I-cache loads across multiple packets.
|
|
|
|
|
2019-10-27 17:28:10 -04:00
|
|
|
* The inefficiencies associated with the deep call stack by receiving vectors
|
2018-07-26 12:45:10 -04:00
|
|
|
of up to 256 packets at a time from the Network Interface, and processes them
|
|
|
|
using a directed graph of node. The graph scheduler invokes one node dispatch
|
|
|
|
function at a time, restricting stack depth to a few stack frames.
|
|
|
|
|
|
|
|
The further optimizations that this approaches enables are pipelining and
|
|
|
|
prefetching to minimize read latency on table data and parallelize packet loads
|
|
|
|
needed to process packets.
|
|
|
|
|
2019-11-06 10:58:28 -08:00
|
|
|
Press next for more on Packet Processing Graphs.
|