paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Merlin: Multi-tier Optimization of eBPF Code for Performance and Compactness

Merlin:面向性能与紧凑性的 eBPF 代码多层次优化
ASPLOS Proceedings of the 29th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 32024匹配度 2/10 · 论文属于编译器优化与 eBPF 代码生成方向,与用户关注的 PL↔AI、LLM/Agent 改进静态分析、浮点程序分析及贝叶斯程序分析均无直接交集;仅在广义程序语言/编译工程上相邻,且不涉及 LLM 或静态分析。引用 15 inbox
Jinsong Mao, Hailun Ding, Juan Zhai, Shiqing Ma
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出 Merlin,利用定制 LLVM pass 与字节码重写对 eBPF 程序做指令合并与强度削减,显著减少指令数并降低运行时开销。

eBPF 是基于寄存器的内核虚拟机,其定制 ISA 对指令数量有严格限制并需通过内核安全验证,因此 eBPF 程序必须经过大量优化才能达到性能目标。然而现有编译器往往忽略关键优化机会,生成代码性能次优。本文提出 Merlin,一个结合定制 LLVM pass 与字节码重写的优化框架,用于中间表示(IR)变换与字节码精化,并采用指令合并与强度削减两种主要优化策略;这些优化均在 eBPF 验证之前实施。作者在 19 个 XDP 程序(来自 Linux 内核、Meta、hXDP 和 Cilium)以及三个基于 eBPF 的系统(Sysdig、Tetragon、Tracee,各包含数百个 eBPF 程序)上评估 Merlin。结果表明,所有优化后程序均通过内核验证,指令数减少 73%、运行时开销降低 60%;与当前最优技术 K2 相比,吞吐量提升 0.59%、延迟降低 5.31%,同时速度快 106 倍,并能更好地扩展到更大更复杂的程序,且无需额外人工介入。

问题
eBPF 的 ISA 指令数受限且内核验证严格,而现有编译器未充分挖掘优化机会,导致 eBPF 程序性能与代码紧凑性不佳。
方法
Merlin 通过定制 LLVM pass 与字节码重写实现 IR 变换和字节码精化,在 eBPF 验证之前应用指令合并与强度削减两类优化策略。
评估
在 19 个 XDP 程序与 Sysdig、Tetragon、Tracee 三个含数百个 eBPF 程序的系统上评估,验证优化后程序均可通过内核验证;指令数减少 73%、运行时开销降低 60%,并优于 K2(吞吐 +0.59%、延迟 -5.31%,快 106 倍且扩展性更好)。
原文摘要(Abstract)

eBPF (extended Berkeley Packet Filter) significantly enhances observability, performance, and security within the Linux kernel, playing a pivotal role in various real-world applications. Implemented as a register-based kernel virtual machine, eBPF features a customized Instruction Set Architecture (ISA) with stringent kernel safety requirements, e.g., a limited number of instructions. This constraint necessitates substantial optimization efforts for eBPF programs to meet performance objectives. Despite the availability of compilers supporting eBPF program compilation, existing tools often overlook key optimization opportunities, resulting in suboptimal performance. In response, this paper introduces Merlin, an optimization framework leveraging customized LLVM passes and bytecode rewriting for Instruction Representation (IR) transformation and bytecode refinement. Merlin employs two primary optimization strategies, i.e., instruction merging and strength reduction. These optimizations are deployed before eBPF verification. We evaluate Merlin across 19 XDP programs (drawn from the Linux kernel, Meta, hXDP, and Cilium) and three eBPF-based systems (Sysdig, Tetragon, and Tracee, each comprising several hundred eBPF programs). The results show that all optimized programs pass the kernel verification. Meanwhile, Merlin can reduce number of instructions by 73% and runtime overhead by 60% compared with the original programs. Merlin can also improve the throughput by 0.59% and reduce the latency by 5.31%, compared to state-of-the-art technique K2, while being 106 times faster and more scalable to larger and more complex programs without additional manual efforts.

链接与引用

DOI 原文 · PDF(开放获取) · DBLP

BibTeX
@inproceedings{MaoDZM24,
  title = {Merlin: Multi-tier Optimization of eBPF Code for Performance and Compactness},
  author = {Jinsong Mao and Hailun Ding and Juan Zhai and Shiqing Ma},
  booktitle = {ASPLOS},
  year = {2024},
  doi = {10.1145/3620666.3651387}
}