P4-Research/nikss-p4c

Implement "Egress co-opting" optimization for XDP

Closed this issue · 1 comments

Currently, we "emulate" egress processing for XDP by using XDP program attached to DEVMAP.

According to the performance tests that we made, it turns out that the overhead of calling the egress program might be significant, especially for the XDP hook. The overhead has several root causes such as the overhead of calling another program, the overhead of passing a bridged metadata (calling adjust_head() helper twice) that could be avoided, and the overhead of parsing packet again in the egress program.

According to the PSA specification, the egress processing makes sense due to two reasons:

  • Last-nanosecond changes to the packet - if you want to measure the queuing latency through the device and (optionally) put the measurements into a packet, it is only possible if the egress processing is used.
  • Multicast efficiency and flexibility - it is possible to modify packets that has been cloned inside the egress pipeline

In the case of PSA-eBPF, both of these rationales are valid, but only for TC. In the XDP mode, we don't perform packet cloning at the XDP level, a packet is being transferred to the TC layer instead. Additionally, it does not make sense at the XDP level to measure queueing latency as there is no queuing between ingress and egress XDP program. As a matter of fact, there is also no queuing at the TC layer, but due to the fact that there is the egress hook the latency between ingress and egress might be more meaningful (e.g. may include the overhead of context switching).

Therefore, we should implement the "egress co-opting" only for XDP and this should give us a noticeable performance improvement.

Closed by #217