一句话:首个 WebAssembly 非侵入式动态插桩系统,提供分层可编程探针并复用 JIT、解释器与去优化机制。
托管运行时相较硬件的一大优势是能通过插桩洞察程序的动态执行,代码覆盖率、执行频次、追踪与调试等分析在虚拟环境中都更易实现。WebAssembly 作为可移植的低层字节码,提供了廉价且高性能的进程内沙箱,但现有 Wasm 引擎对执行中程序的可见性很有限,至多支持字节码级单步与基本源映射,缺乏插桩能力。本文在开源 Wizard Research Engine 中提出了首个面向 WebAssembly 的非侵入式动态插桩系统。其设计给出了一套灵活而完整的插桩原语层次结构,使高层复杂分析可基于低层可编程探针构建。与仿真或机器码插桩不同,在字节码层注入探针提升了表达能力,并通过复用引擎已有的 JIT 编译器、解释器与去优化机制大幅简化实现。Wizard 支持插桩的动态插入与移除,并提供一致性保证,从而避免多个分析相互干扰。文中详述了在高性能多层级 Wasm 引擎中的完整实现,给出了为降低插桩开销而设计的若干新优化,并在多种分析负载下评估了性能特征;当探针未被使用时可不影响生产性能,因而适合被产品级引擎采纳。
A key strength of managed runtimes over hardware is the ability to gain detailed insight into the dynamic execution of programs with instrumentation. Analyses such as code coverage, execution frequency, tracing, and debugging, are all made easier in a virtual setting. As a portable, low-level byte-code, WebAssembly offers inexpensive in-process sandboxing with high performance. Yet to date, Wasm engines have not offered much insight into executing programs, supporting at best bytecode-level stepping and basic source maps, but no instrumentation capabilities. In this paper, we show the first non-intrusive dynamic instrumentation system for WebAssembly in the open-source Wizard Research Engine. Our innovative design offers a flexible, complete hierarchy of instrumentation primitives that support building high-level, complex analyses in terms of low-level, programmable probes. In contrast to emulation or machine code instrumentation, injecting probes at the bytecode level increases expressiveness and vastly simplifies the implementation by reusing the engine's JIT compiler, interpreter, and deoptimization mechanism rather than building new ones. Wizard supports both dynamic instrumentation insertion and removal while providing consistency guarantees, which is key to composing multiple analyses without interference. We detail a fully-featured implementation in a high-performance multi-tier Wasm engine, show novel optimizations specifically designed to minimize instrumentation overhead, and evaluate performance characteristics under load from various analyses. This design is well-suited for production engine adoption as probes can be implemented to have no impact on production performance when not in use.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{abs-2403-07973,
title = {Flexible Non-intrusive Dynamic Instrumentation for WebAssembly},
author = {Ben L. Titzer and Elizabeth Gilbert and Bradley Wei Jie Teo and Yash Anand and Kazuyuki Takayama and Heather Miller},
booktitle = {ASPLOS},
year = {2024},
doi = {10.1145/3620666.3651338}
}