This repository contains the source code and benchmarking suite for my Collegio Superiore's final Thesis: "Kernel-level Hedged Requests via eBPF"
This project demonstrates how moving reliability logic (Request Hedging) from User Space (Application) to Kernel Space (eBPF) eliminates User Space Jitter (caused by Garbage Collection and Process Scheduling), resulting in a 96% reduction in P99 latency.
- Oblvious Client: No changes required to the application code. The eBPF program attaches to the network interface (
lo) transparently. - Kernel Precision: Hedging timers run in kernel context (SoftIRQ), immune to Python/Java GC pauses.
- Deterministic Benchmarking: Includes a custom UDP server with "Deterministic Chaos" fault injection to scientifically compare algorithms.
- Smart Networking: Solves low-level challenges like Checksum Offloading and Martian Packet routing.
| Method | P99 Latency | Max Latency (Jitter) |
|---|---|---|
| Baseline | 401.14 ms | 401.60 ms |
| App-Hedged (Python) | 13.08 ms | 22.09 ms (High Jitter) |
| Kernel-Hedged (eBPF) | 12.83 ms | 13.35 ms (Stable) |
The Kernel implementation is only slighly better than the Application P99 but eliminates the 9ms+ jitter spike caused by user-space scheduling.
- Splitter (TC Egress): Intercepts and clones outgoing UDP packets.
- Delay Line: Uses
vethpairs +netemto buffer packets in the kernel. - Rescuer (TC Ingress): Checks the shared BPF Map (
scoreboard). If the original request hasn't received an ACK, it modifies and re-injects the cloned packet.
- Linux Kernel 5.x+ (Headers installed)
bcc(BPF Compiler Collection)ethtool(To disable checksum offloading)matplotlib
- Install matplotlib:
pip install matplotlib
- Start the Deterministic Server:
python3 server_dual.py
- Load the eBPF Program:
sudo python3 ebpf_final_hedge.py
- Run the Benchmark:
python3 benchmark_suite.py
/src: C (eBPF) and Python source code./thesis: LaTeX source code for the Master's Thesis document./plots: Plots produced by the benchmarking code.
If you use this code, please cite:
Matteo Fornaini, "Kernel-level Hedged Requests via eBPF", Final Thesis, Collegio Superiore of the University of Bologna, 2026.