Distinguishability-Guided Test Program Generation for WebAssembly Runtime Performance Testing

Shuyao Jiang, Ruiying Zeng, Yangfan Zhou, Michael R. Lyu

TL;DR

WarpGen is a novel test program generator designed to uncover performance bugs in WebAssembly (Wasm) runtimes. By combining historical code patterns with a new "distinguishability" metric, it automatically synthesizes programs that push runtimes to their performance limits, successfully identifying seven previously unknown issues in popular engines like Wasmtime and Wasmer.

What Problem Does This Paper Address?

WebAssembly is no longer just for the browser; it’s powering cloud-native services, microcontrollers, and smart contracts. Because high performance is a core design goal of Wasm, the runtimes (the engines that execute the code) must be lightning-fast. However, standalone runtimes like WasmEdge or WAMR are still maturing and often harbor "performance bugs"—scenarios where specific code runs significantly slower than it should.

The challenge is that we don't have enough high-quality test programs to find these bugs. Existing tools like Csmith are great at finding functional bugs (code that crashes), but they aren't tailored to trigger performance anomalies. Furthermore, without a "ground truth" for how fast a piece of code should run, it’s hard to tell if a runtime is being slow or if the code is just computationally expensive.

Methods

The authors introduce WarpGen, which uses a two-pronged approach:

  1. History-Driven Synthesis: Instead of generating code from scratch, WarpGen extracts "operators" (code snippets) from historical programs known to have triggered performance issues in the past. It then intelligently inserts these operators into "seed" programs (simple, valid C programs).
  2. Distinguishability-Guided Generation: This is the core innovation. To determine if a generated program is "high quality," the authors define a distinguishability score (dist score).
  3. They run the same program across multiple Wasm runtimes (e.g., Wasmtime, Wasmer, WAMR).
  4. They calculate an "oracle ratio"—the average execution time ratio across all tests.
  5. The dist score is the Euclidean distance between a specific program's execution time vector and that oracle ratio.
  6. The Logic: If a program runs much slower on one runtime compared to the others (relative to the norm), it has a high dist score and is likely triggering a performance bug.

WarpGen uses an iterative process: it keeps the operators that produce high dist scores and discards those that don't (using a penalty mechanism), effectively "evolving" the test suite toward more effective bug-finding.

Datasets

  • Initial Operators: 271 code snippets extracted from 20 abnormal programs previously reported by the WarpDiff tool. These snippets cover sequential, branching, and looping logic.
  • Seed Programs: 100 C programs generated by Csmith to serve as the "base" for code insertion.
  • Test Objects (Runtimes): Four major standalone Wasm runtimes: Wasmer, Wasmtime, WasmEdge, and WAMR.

Key Insights and Ideas

  • Performance as a Relative Metric: You don't need an absolute "perfect" execution time to find a bug. By comparing multiple runtimes against each other (differential testing), the "odd one out" reveals the flaw.
  • Context Matters: A code snippet might not be slow on its own, but when inserted into a loop or a specific function context in a seed program, it can trigger a bottleneck. WarpGen found that the interaction between the inserted code and the seed program's logic was often the key to uncovering the bug.
  • Guidance vs. Randomness: The study proved that "distinguishability" is a powerful North Star. WarpGen reached optimal bug-triggering scores much faster than unguided or purely random approaches (like Csmith), which often produced "flat" performance profiles across all runtimes.

Key Results

  • New Bug Discovery: WarpGen identified 7 new performance issues across three major runtimes.
  • Wasmtime: Issues with floating-point arithmetic, pointer access to constants, and nested loop increments.
  • Wasmer: Issues with floating-point arrays, standard output calls, and variable address access.
  • WAMR: Issues with floating-point arithmetic optimization.
  • Impact: All seven issues were confirmed by the respective development teams, and four have already been fixed.
  • Efficiency: WarpGen's final test programs had dist scores four times higher than those generated by Csmith, meaning they were significantly better at highlighting runtime-specific weaknesses.

Limitations and Future Work

  • Operator Diversity: WarpGen currently relies on a relatively small pool of historical operators. As more performance issues are discovered, this pool will need to grow to maintain effectiveness.
  • Parameter Tuning: The tool’s efficiency depends on several hyperparameters (like the penalty threshold $M$ and the number of top programs $N$). While the authors found sweet spots for their tests, these might vary for different types of software.
  • Language Scope: Currently, the tool focuses on C-based Wasm programs. Future work could involve extending this to other languages that compile to Wasm, such as Rust or Go, which might trigger different performance paths in the runtimes.

Summary updated

BibTeX
@inproceedings{jiang2025distinguishability,
  author = {Shuyao Jiang and Ruiying Zeng and Yangfan Zhou and Michael R. Lyu},
  title = {{Distinguishability-Guided Test Program Generation for WebAssembly Runtime Performance Testing}},
  booktitle = {SANER},
  year = {2025},
  doi = {10.1109/saner64311.2025.00078},
}
Figure