Flexible Non-intrusive Dynamic Instrumentation for WebAssembly (2403.07973v1)
Abstract: 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 bytecode, 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.
- The edge of the multi-cloud. https://www.fastly.com/cassets/6pk8mg3yh2ee/79dsHLTEfYIMgUwVVllaa4/5e5330572b8f317f72e16696256d8138/WhitePaper-Multi-Cloud.pdf, 2020. (Accessed 2021-07-06).
- Wasm3: The fastest WebAssembly interpreter, and the most universal runtime. https://github.com/wasm3/wasm3, 2020. (Accessed 2021-08-11).
- Java Virtual Machine Tools Interface. https://docs.oracle.com/javase/8/docs/technotes/guides/jvmti/, 2021. (Accessed 2021-07-29).
- JavaScriptCore, the built-in JavaScript engine for WebKit. https://trac.webkit.org/wiki/JavaScriptCore, 2021. (Accessed 2021-07-29).
- V8 development site. https://v8.dev, 2021. (Accessed 2021-07-29).
- WebAssembly specifications. https://webassembly.github.io/spec/, 2021. (Accessed 2021-07-29).
- 2023.
- Walrus: A WebAssembly transformation library. https://github.com/rustwasm/walrus, 2023.
- Wasm bytecode instrumenter. https://github.com/yashanand1910/wasm-bytecode-instrumenter, 2023.
- SaBRe: load-time selective binary rewriting. International Journal on Software Tools for Technology Transfer, 24(2):205–223, Apr 2022.
- Linux Wiki Authors. Linux perf main page. https://perf.wiki.kernel.org/index.php/Main_Page, 2012. (Accessed 2023-8-4).
- .NET Wiki Authors. The .NET Profiling API. https://learn.microsoft.com/en-us/dotnet/framework/unmanaged-api/profiling/profiling-overview, 2021. (Accessed 2023-8-4).
- TuningFork: A platform for visualization and analysis of complex real-time systems. In Companion to the 22nd ACM SIGPLAN Conference on Object-Oriented Programming Systems and Applications Companion, OOPSLA ’07, page 854–855, New York, NY, USA, 2007. Association for Computing Machinery.
- Fabrice Bellard. QEMU: A generic and open source machine emulator and virtualizer. http://qemu.org, 2020. (Accessed 2023-8-07).
- Anywhere, any-time binary instrumentation. In Proceedings of the 10th ACM SIGPLAN-SIGSOFT Workshop on Program Analysis for Software Tools, PASTE ’11, page 9–16, New York, NY, USA, 2011. Association for Computing Machinery.
- Advanced Java bytecode instrumentation. In Proceedings of the 5th International Symposium on Principles and Practice of Programming in Java, PPPJ ’07, page 135–144, New York, NY, USA, 2007. Association for Computing Machinery.
- Provably-safe multilingual software sandboxing using WebAssembly. In Proceedings of the USENIX Security Symposium, August 2022.
- An infrastructure for adaptive dynamic optimization. In International Symposium on Code Generation and Optimization, 2003. CGO 2003. IEEE Comput. Soc, 2003.
- Runtime object lifetime profiler for latency sensitive big data applications. In Proceedings of the Fourteenth EuroSys Conference 2019, EuroSys ’19, New York, NY, USA, 2019. Association for Computing Machinery.
- Living on the edge: Rapid-toggling probes with cross-modification on x86. In Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’16, page 16–26, New York, NY, USA, 2016. Association for Computing Machinery.
- Greg Cooper. DTrace: Dynamic tracing in Oracle Solaris, Mac OS X, and Free BSD by Brendan Gregg and Jim Mauro. SIGSOFT Softw. Eng. Notes, 37(1):34, jan 2012.
- Frank Denis. Libsodium, 2021.
- Dynamic metrics for Java. SIGPLAN Not., 38(11):149–168, oct 2003.
- The RoadRunner dynamic analysis framework for concurrent programs. In Proceedings of the 9th ACM SIGPLAN-SIGSOFT Workshop on Program Analysis for Software Tools and Engineering, PASTE ’10, page 1–8, New York, NY, USA, 2010. Association for Computing Machinery.
- Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley Professional Computing Series. Pearson Education, 1994.
- Side effect monitoring for Java using bytecode rewriting. In Proceedings of the 2014 International Conference on Principles and Practices of Programming on the Java Platform: Virtual Machines, Languages, and Tools, PPPJ ’14, page 87–98, New York, NY, USA, 2014. Association for Computing Machinery.
- DTrace: Dynamic Tracing in Oracle Solaris, Mac OS X and FreeBSD. Prentice Hall Press, USA, 1st edition, 2011.
- Bringing the web up to speed with WebAssembly. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2017, page 185–200, New York, NY, USA, 2017. Association for Computing Machinery.
- Numerical computing on the web: Benchmarking for the future. In Proceedings of the 14th ACM SIGPLAN International Symposium on Dynamic Languages, DLS 2018, page 88–100, New York, NY, USA, 2018. Association for Computing Machinery.
- APT-GET: Profile-guided timely software prefetching. In Proceedings of the Seventeenth European Conference on Computer Systems, EuroSys ’22, page 747–764, New York, NY, USA, 2022. Association for Computing Machinery.
- An overview of AspectJ. In Proceedings of the 15th European Conference on Object-Oriented Programming, ECOOP ’01, page 327–353, Berlin, Heidelberg, 2001. Springer-Verlag.
- EEL: Machine-independent executable editing. In Proceedings of the ACM SIGPLAN 1995 Conference on Programming Language Design and Implementation, PLDI ’95, page 291–300, New York, NY, USA, 1995. Association for Computing Machinery.
- Wasabi: A framework for dynamically analyzing WebAssembly. In Proceedings of the Twenty-Fourth International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS ’19, page 1045–1058, New York, NY, USA, 2019. Association for Computing Machinery.
- ThingSpire OS: A WebAssembly-based IoT operating system for cloud-edge integration. In Proceedings of the 19th Annual International Conference on Mobile Systems, Applications, and Services, MobiSys ’21, page 487–488, New York, NY, USA, 2021. Association for Computing Machinery.
- Aerogel: Lightweight access control framework for WebAssembly-based bare-metal IoT devices. In 2021 IEEE/ACM Symposium on Edge Computing (SEC), pages 94–105, 2021.
- Pin: Building customized program analysis tools with dynamic instrumentation. SIGPLAN Not., 40(6):190–200, June 2005.
- ShadowVM: Robust and comprehensive dynamic program analysis for the Java platform. In Proceedings of the 12th International Conference on Generative Programming: Concepts and Experiences, GPCE ’13, page 105–114, New York, NY, USA, 2013. Association for Computing Machinery.
- DiSL: A domain-specific language for bytecode instrumentation. In Proceedings of the 11th Annual International Conference on Aspect-Oriented Software Development, AOSD ’12, page 239–250, New York, NY, USA, 2012. Association for Computing Machinery.
- The Paradyn parallel performance measurement tool. Computer, 28(11):37–46, nov 1995.
- Oron: Towards a dynamic analysis instrumentation platform for AssemblyScript. In Companion Proceedings of the 5th International Conference on the Art, Science, and Engineering of Programming, Programming ’21, page 6–13, New York, NY, USA, 2021. Association for Computing Machinery.
- Retrofitting industrial machines with WebAssembly on the edge. In Richard Chbeir, Helen Huang, Fabrizio Silvestri, Yannis Manolopoulos, and Yanchun Zhang, editors, Web Information Systems Engineering – WISE 2022, pages 241–256, Cham, 2022. Springer International Publishing.
- Valgrind: A framework for heavyweight dynamic binary instrumentation. SIGPLAN Not., 42(6):89–100, jun 2007.
- Edgedancer: Secure mobile WebAssembly services on the edge. In Proceedings of the 4th International Workshop on Edge Systems, Analytics and Networking, EdgeSys ’21, page 13–18, New York, NY, USA, 2021. Association for Computing Machinery.
- Nathaniel John Nystrom. Bytecode-level analysis and optimization of Java classes. Master’s thesis, Purdue University, August 1998.
- Louis-Noël Pouchet. PolyBench, May 2016.
- Towards solving the challenge of minimal overhead monitoring. In Companion of the 2023 ACM/SPEC International Conference on Performance Engineering, ICPE ’23 Companion, page 381–388, New York, NY, USA, 2023. Association for Computing Machinery.
- Aspect-oriented WebAssembly transformation. In 2022 17th Iberian Conference on Information Systems and Technologies (CISTI), pages 1–6, 2022.
- Instrumentation and optimization of Win32/Intel executables using Etch. In Proceedings of the USENIX Windows NT Workshop on The USENIX Windows NT Workshop 1997, NT’97, page 1, USA, 1997. USENIX Association.
- Jalangi: A selective record-replay and dynamic analysis framework for JavaScript. In Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2013, page 488–498, New York, NY, USA, 2013. Association for Computing Machinery.
- BISM: bytecode-level instrumentation for software monitoring. In Runtime Verification: 20th International Conference, RV 2020, Los Angeles, CA, USA, October 6–9, 2020, Proceedings 20, pages 323–335. Springer, 2020.
- Vulcan: Binary transformation in a distributed environment. Technical report, Microsoft Research, 2001.
- ATOM: A system for building customized program analysis tools. New York, NY, USA, 1994. Association for Computing Machinery.
- Ben L. Titzer. Harmonizing classes, functions, tuples, and type parameters in Virgil III. In Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’13, page 85–94, New York, NY, USA, 2013. Association for Computing Machinery.
- Ben L. Titzer. Wizard, An advanced Webassembly Engine for Research. https://github.com/titzer/wizard-engine, 2021. (Accessed 2021-07-29).
- Ben L. Titzer. A fast in-place interpreter for WebAssembly. Proc. ACM Program. Lang., 6(OOPSLA2), October 2022.
- Ben L. Titzer. Whose baseline compiler is it anyway? CGO ’24, New York, NY, USA, 2024. Association for Computing Machinery.
- Avrora: Scalable sensor network simulation with precise timing. In Proceedings of the 4th International Symposium on Information Processing in Sensor Networks, IPSN ’05, page 67–es. IEEE Press, 2005.
- Nonintrusive precision instrumentation of microcontroller software. In Proceedings of the 2005 ACM SIGPLAN/SIGBED Conference on Languages, Compilers, and Tools for Embedded Systems, LCTES ’05, page 59–68, New York, NY, USA, 2005. Association for Computing Machinery.
- Soot: A Java bytecode optimization framework. In CASCON First Decade High Impact Papers, CASCON ’10, page 214–224, USA, 2010. IBM Corp.
- Kenton Varda. WebAssembly on Cloudflare Workers. https://blog.cloudflare.com/webassembly-on-cloudflare-workers/. (Accessed 2021-07-06).
- Odin: On-demand instrumentation with on-the-fly recompilation. In Proceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation, PLDI 2022, page 1010–1024, New York, NY, USA, 2022. Association for Computing Machinery.
- Conrad Watt. Mechanising and verifying the WebAssembly specification. In Proceedings of the 7th ACM SIGPLAN International Conference on Certified Programs and Proofs, CPP 2018, page 53–65, New York, NY, USA, 2018. Association for Computing Machinery.
- From hack to elaborate technique – a survey on binary rewriting. ACM Comput. Surv., 52(3), jun 2019.
- JPortal: Precise and efficient control-flow tracing for JVM programs with Intel Processor Trace. In Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation, PLDI 2021, page 1080–1094, New York, NY, USA, 2021. Association for Computing Machinery.
- Ben L. Titzer (10 papers)
- Elizabeth Gilbert (3 papers)
- Bradley Wei Jie Teo (2 papers)
- Yash Anand (4 papers)
- Kazuyuki Takayama (1 paper)
- Heather Miller (16 papers)