一句话:提出 Zircon:首个优化器友好的事件量化插桩,用局部计数器与 PRUE 算法消除冗余更新,大幅降低开销。
事件量化通过插桩为运行时事件提供频率信息,广泛用于构建快速、安全、可靠的软件系统,但插桩引入的新指令会带来显著运行时开销。核心挑战在于:插桩指令的副作用会干扰现代编译器优化,使其难以从中获益。已有工作尝试用具有透明生命周期和作用域的局部计数器替代全局计数器,从而让优化更容易成功,但局部计数器对外部不可观测,仍需全局计数器,而何时依据局部计数器更新全局计数器本身又会引入副作用。本文提出部分冗余更新消除(PRUE)算法来解决更新决策问题,并实现 Zircon——首个优化器友好的事件量化插桩系统。Zircon 借助局部计数器将事件发生与量化分离,把带副作用的指令移出优化器作用域,再通过静态分析变换程序并剪除冗余更新路径。在 SPEC CPU 2017 上,Zircon 相比 SanCov 和 Nisse 等最先进工作最高快 149%,且不牺牲精度,充分借助编译器优化自动获得性能收益。
Event quantification provides frequency information for runtime events and is widely used to build fast, secure, and reliable software and systems. It is usually achieved through instrumentation that introduces new instructions into programs but has significant runtime overhead. A key challenge in developing efficient instrumentation is that the instrumentation can barely benefit from modern compiler optimizations because the additional instructions introduce side effects that complicate the optimization process. One intuitive idea to mitigate the side effect issue is to use local counters with transparent lifetimes and scopes instead of relying on global counters. Optimizations are more likely to succeed on instructions that manipulate local variables rather than global ones. However, this idea is not fully adequate, as local counters are unobservable to external users of the quantification data. Therefore, global counters are still necessary, and it is essential to determine when to update them based on the local counters. The challenge is that these updates also introduce side effects that hinder optimizations. We address this update decision problem with the Partially Redundant Update Elimination (PRUE). We present Zircon, the first optimizer-friendly instrumentation to quantify runtime events. With the help of local counters, Zircon separates the event occurrence and the quantification by moving the instructions with side effects outside the scope where the optimizers apply. However, this separation introduces redundant instructions; the additional instructions would still be executed even without event occurrence. In other words, the lifetime control of the local counters challenges the efficiency of instrumentation. PRUE transforms the program and prunes away paths with redundant updates based on static analysis. The evaluation on the SPEC CPU 2017 shows that Zircon is up to 149% faster than state-of-the-art work, including SanCov and Nisse. Unlike existing efforts, Zircon does not compromise accuracy for efficiency; instead, it fully harnesses the power of compilation optimizers and delivers automatic performance gains.