一句话:EPSO 通过离线超优化发现重写规则并缓存复用,实现对 eBPF 字节码高质量、低开销的自动优化。
eBPF 允许开发者在不修改内核源码的前提下扩展内核功能,但内核验证器对加载的程序施加了严格安全约束(如程序大小限制),加上 eBPF 多用于性能敏感场景,高效优化因此十分关键。现有编译器(如 Clang)优化能力有限,而许多保持语义的变换会被验证器拒绝,导致手工设计优化规则既困难又效果受限。超优化能自动发现最优变换,但计算开销大、难以扩展。为此,作者提出 EPSO:一种基于缓存的超优化器,先离线通过超优化自动发现重写规则,再在运行时复用这些规则,以极小的运行时开销获得高质量优化。作者在 Linux 内核及 Cilium、Katran、hXDP、Sysdig、Tetragon、Tracee 等 eBPF 项目的基准上评估:EPSO 共发现 795 条重写规则,相比 Clang 输出程序大小最多减少 68.87%(平均 24.37%),在所有基准上优于当前最优的 BPF 优化器 K2,并在 92.68% 的基准上优于 Merlin;同时程序运行时间平均降低 6.60%,提升了网络应用的吞吐并降低了延迟。
Extended Berkeley Packet Filter (eBPF) allows developers to extend Linux kernel functionality without modifying its source code. To ensure system safety, an in-kernel safety checker, the verifier, enforces strict safety constraints (e.g., a limited program size) on eBPF programs loaded into the kernel. These constraints, combined with eBPF’s performance-critical use cases, make effective optimization essential. However, existing compilers (e.g., Clang) offer limited optimization support, and many semantics-preserving transformations are rejected by the verifier, which makes handcrafted optimization rule design both challenging and limited in effectiveness.Superoptimization overcomes the limitations of rule-based methods by automatically discovering optimal transformations, but its high computational cost limits scalability. To address this, we propose EPSO, a caching-based superoptimizer that discovers rewrite rules via offline superoptimization, and reuses them to achieve high-quality optimizations with minimal runtime overhead. We evaluate EPSO on benchmarks from the Linux kernel and several eBPF-based projects, including Cilium, Katran, hXDP, Sysdig, Tetragon, and Tracee. EPSO discovers 795 rewrite rules and achieves up to 68.87% (avg. 24.37%) reduction in program size compared to Clang’s output, outperforming the state-of-the-art BPF optimizer K2 on all benchmarks and Merlin on 92.68% of them. Additionally, EPSO reduces program runtime by an average of 6.60%, improving throughput and lowering latency in network applications.
DOI 原文 ·
@inproceedings{paperbot9457,
title = {EPSO: A Caching-Based Efficient Superoptimizer for BPF Bytecode},
author = {Qian Zhu and Yuxuan Liu and Ziyuan Zhu and Shangqing Liu and Lei Bu},
booktitle = {ASE},
year = {2025},
doi = {10.1109/ase63991.2025.00242}
}