P4COM: In-Network Computation with Programmable Switches

Ge Chen, Gaoxiong Zeng, Li Chen

Abstract

Traditionally, switches only provide forwarding services and have no credits on computation in distributed computing frameworks. The emerging programmable switches make in-network computing (INC) possible, i.e., offloading some computation to the switch data plane. While some proposals have attempted to offload computation onto special hardwares (e.g., NetFPGA), many practical issues have not been addressed. Therefore, we propose P4COM - a user-friendly, memory-efficient, and fault-tolerant framework realizing in-network computation (e.g., MapReduce) with programmable switches. P4COM consists of three modules. First, P4COM automatically translates application logic to switch data plane programs with a lightweight interpreter. Second, P4COM adopts a memory management policy to efficiently utilize the limited switch on-chip memory. Third, P4COM provides a cutting-payload mechanism to handle packet losses. We have built a P4COM prototype with a Barefoot Tofino switch and multiple commodity servers. Through a combination of testbed experiments and large-scale simulations, we show that P4COM is able to achieve line-rate processing at 10Gbps links, and can increase the data shuffling throughput by 2-5 times for the MapReduce-style applications.

The Bottleneck of Distributed Computing

In modern data centers, distributed computing frameworks like MapReduce, Spark, and distributed Deep Learning (DL) training are the workhorses of big data processing. However, these frameworks often hit a wall during the "shuffle" phase. This phase requires moving massive amounts of intermediate data from many "mapper" nodes to a few "reducer" nodes. This many-to-one communication pattern creates a severe network bottleneck known as the Incast problem, where switch buffers overflow and throughput plummets. In fact, studies show that aggregation traffic can account for nearly 50% of the total network load in large-scale clusters.

Evolution of data aggregation architectures: (a) Conventional MapReduce, (b) Middlebox aggregation, and (c) In-network computation with P4COM.

To mitigate this, researchers have explored In-Network Computation (INC). The idea is simple: instead of just forwarding packets, why not have the network switches perform partial data aggregation as the data passes through them? By aggregating values "on the wire," the amount of data that actually reaches the final reducer is significantly reduced.

Challenges in Realizing INC

While the concept is promising, implementing INC on commodity programmable switches (using the P4 language) faces three major hurdles:

  1. Usability: P4 is a domain-specific language for packet processing, not general-purpose computation. Writing complex reduction logic in P4 is difficult for application developers who are used to high-level languages like Java or Python.
  2. Memory Constraints: Switches are designed for speed, not storage. They typically have only a few megabytes of on-chip SRAM, whereas distributed jobs often process gigabytes or terabytes of data with millions of unique keys.
  3. Reliability: Standard network protocols assume switches are "dumb" forwarders. If a switch aggregates a value and the resulting packet is lost, the computation state is corrupted. Conversely, if a packet is retransmitted and the switch processes it twice, the final result will be mathematically incorrect.

The P4COM Framework

P4COM addresses these challenges through a co-designed hardware-software architecture consisting of three core modules.

1. Lightweight Interpreter

To bridge the gap between application logic and switch hardware, P4COM provides a compiler that translates high-level MapReduce-style logic into P4 programs. Developers can use a simplified API to define atomic operations such as SUM, MIN, or MAX. The interpreter automatically maps these operations to the switch's match-action pipelines, shielding the developer from the complexities of hardware registers and ALUs.

2. Dynamic Memory Management

Since switch memory is a scarce resource, P4COM treats the on-chip SRAM as an "active array" or cache for the most frequent intermediate results. To prevent overflow, P4COM implements a "heap" on the mapper side that tracks and approximates the switch's current memory occupancy. When the switch memory reaches a predefined threshold, it triggers a "collection signal" to flush the current results to the master node, freeing up space for new keys while maintaining high utilization.

3. Reliable Transport: The Cutting-Payload Mechanism

To ensure fault tolerance, P4COM introduces a specialized transport mechanism. When a switch successfully processes and aggregates a data packet, it "cuts" the payload (the actual data) but continues to forward the header to the receiver. This header acts as an implicit acknowledgment (ACK). By storing sequence numbers in stateful registers, the switch can detect retransmitted packets and avoid "double-counting" them, ensuring idempotency even in the face of packet loss.

Comparison of data flow: (a) Conventional MapReduce requires multiple packets for the same keys, while (b) P4COM aggregates them in-network, reducing traffic.

Performance Evaluation

The authors evaluated P4COM using a physical testbed featuring a Barefoot Tofino switch and multiple commodity servers, supplemented by large-scale simulations. They tested the framework against diverse workloads, including Wikipedia word counts, web graph processing, and Deep Neural Network (DNN) training (e.g., ResNet50, VGG16).

The results were compelling:

  • Throughput Gains: P4COM increased data shuffling throughput by 2x to 5x compared to conventional MapReduce.
  • Traffic Reduction: In distributed DL training, the volume of data transmitted across the network was reduced by over 60%.
  • Line-Rate Efficiency: The system achieved line-rate processing at 10Gbps, demonstrating that the added computational logic does not introduce latency or throughput penalties for standard packet forwarding.

Conclusion

P4COM demonstrates that programmable switches can do much more than just route traffic; they can become active participants in distributed computation. By providing a developer-friendly interface, managing limited hardware resources intelligently, and ensuring mathematical correctness through a robust transport layer, P4COM paves the way for more efficient and scalable data center architectures.

Summary updated

Abstract

Traditionally, switches only provide forwarding services and have no credits on computation in distributed computing frameworks. The emerging programmable switches make in-network computing (INC) possible, i.e., offloading some computation to the switch data plane. While some proposals have attempted to offload computation onto special hardwares (e.g., NetFPGA), many practical issues have not been addressed. Therefore, we propose P4COM - a user-friendly, memory-efficient, and fault-tolerant framework realizing in-network computation (e.g., MapReduce) with programmable switches. P4COM consists of three modules. First, P4COM automatically translates application logic to switch data plane programs with a lightweight interpreter. Second, P4COM adopts a memory management policy to efficiently utilize the limited switch on-chip memory. Third, P4COM provides a cutting-payload mechanism to handle packet losses. We have built a P4COM prototype with a Barefoot Tofino switch and multiple commodity servers. Through a combination of testbed experiments and large-scale simulations, we show that P4COM is able to achieve line-rate processing at 10Gbps links, and can increase the data shuffling throughput by 2-5 times for the MapReduce-style applications.
BibTeX
@misc{chen2021p,
  author = {Ge Chen and Gaoxiong Zeng and Li Chen},
  title = {{P4COM: In-Network Computation with Programmable Switches}},
  year = {2021},
  eprint = {2107.13694},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2107.13694},
}

Loading related content...

Figure