Efficient Data Exchange between WebAssembly Modules
Abstract
:1. Introduction
2. Background
3. Related Work
3.1. Inter-Module Communication
3.2. Serialization
3.3. Conclusions
4. Karmem Approach
4.1. Schema Language
4.1.1. Compilation Attributes
4.1.2. Existing Language
4.1.3. KarmemIDL
4.2. Data Layout
4.2.1. Structs
4.2.2. Arrays
4.2.3. Unions
4.2.4. Evolution
4.2.5. Flatten
4.3. Communication
4.3.1. Code Generator
4.3.2. Interface and Patterns
4.3.3. Shared Memories
4.3.4. Runtime
5. Results and Discussion
5.1. Performance Analysis
5.1.1. Methodology
5.1.2. Dynamic Structures Test
5.1.3. Dynamic Structures Test Results
5.2. Generated Code
5.2.1. Experiment
5.2.2. Performance
5.2.3. Integrity
5.2.4. Usage
6. Conclusions and Future Work
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Dis Virtual Machine Specification. Available online: https://www.vitanuova.com/inferno/papers/dis.html (accessed on 16 October 2023).
- Rose, J.R. Bytecodes meet Combinators: Invokedynamic on the JVM. In Proceedings of the Third Workshop on Virtual Machines and Intermediate Languages, Orlando, FL, USA, 25–29 October 2009; pp. 1–11. [Google Scholar]
- Hickey, P. Lucet Takes WebAssembly Beyond the Browser|Fastly|Fastly. Available online: https://www.fastly.com/blog/announcing-lucet-fastly-native-webassembly-compiler-runtime (accessed on 16 October 2023).
- Varda, K. WebAssembly on Cloudflare Workers. Available online: https://blog.cloudflare.com/webassembly-on-cloudflare-workers/ (accessed on 16 October 2023).
- Bytecodealliance/Wasm-Micro-Runtime: WebAssembly Micro Runtime (WAMR). Available online: https://github.com/bytecodealliance/wasm-micro-runtime (accessed on 16 October 2023).
- Dale, B. Gavin Wood: WebAssembly Is the Future, EVM Is Right Now—CoinDesk. Available online: https://www.coindesk.com/tech/2021/05/25/polkadots-gavin-wood-webassembly-is-the-future-of-smart-contracts-but-legacy-evm-is-right-now/ (accessed on 16 October 2023).
- Charriere, P. Give Super Powers to Java with WebAssembly by Philippe Charriere @ Wasm I/O 2023—YouTube. Available online: https://www.youtube.com/watch?v=5HBglrvHtWg (accessed on 16 October 2023).
- Shuralyov, D. Syscall/js: Performance Considerations—Issue #32591—Golang/Go. Available online: https://github.com/golang/go/issues/32591 (accessed on 16 October 2023).
- Denis. [Interface Types] Avoid Memory Copy—Issue #88—WebAssembly/Interface-Types. Available online: https://github.com/WebAssembly/interface-types/issues/88 (accessed on 16 October 2023).
- Sikora, P. WebAssembly in Envoy. Available online: https://github.com/proxy-wasm/spec/blob/master/docs/WebAssembly-in-Envoy.md#drawbacks (accessed on 16 October 2023).
- Fioretti, M. How and Why to Link WebAssembly Modules. Available online: https://training.linuxfoundation.org/blog/how-and-why-to-link-webassembly-modules/ (accessed on 16 October 2023).
- WebAssembly|web.dev. Available online: https://web.dev/explore/webassembly?hl=pt-br (accessed on 16 October 2023).
- Intel Confirms Arrow Lake-S & Lunar Lake CPUs will Support Instructions for AVX-VNNI, SHA512, SM3, SM4 and LAM—VideoCardz.com. Available online: https://videocardz.com/newz/intel-confirms-arrow-lake-s-lunar-lake-cpus-will-support-instructions-for-avx-vnni-int16-sha512-sm3-sm4-and-lam (accessed on 18 November 2023).
- Design/Nondeterminism.md at Main—WebAssembly/Design—GitHub. Available online: https://github.com/WebAssembly/design/blob/main/Nondeterminism.md (accessed on 10 November 2023).
- WIT—The WebAssembly Component Model. Available online: https://component-model.bytecodealliance.org/design/wit.html#options (accessed on 26 January 2023).
- WASI/legacy/preview1/witx/wasi_snapshot_preview1.witx. Available online: https://github.com/WebAssembly/WASI/blob/41c4383548ba7a06df5df7232b68a6f0bbb93e2d/legacy/preview1/witx/wasi_snapshot_preview1.witx (accessed on 16 October 2023).
- Denis, F. Jedisct1/Witx-Codegen: WITX Code and Documentation Generator for AssemblyScript, Zig, Rust and More. Available online: https://github.com/jedisct1/witx-codegen (accessed on 16 October 2023).
- waPC.io|waPC.io. Available online: https://wapc.io/ (accessed on 16 October 2023).
- Fukuda, T. knqyf263/go-plugin: Go Plugin System over WebAssembly. Available online: https://github.com/knqyf263/go-plugin (accessed on 16 October 2023).
- Canonical ABI—The WebAssembly Component Model. Available online: https://component-model.bytecodealliance.org/design/canonical-abi.html (accessed on 26 January 2023).
- WebAssembly Contributors. WebAssembly/Proposals: Tracking WebAssembly Proposals. Available online: https://github.com/WebAssembly/proposals (accessed on 17 October 2023).
- Overview|Extism—Make all Software Programmable. Extend from within. Available online: https://extism.org/docs/overview/#example-in-action (accessed on 16 October 2023).
- Dylibso. Host Functions|Extism—Make All Software Programmable. Extend from within. Available online: https://extism.org/docs/concepts/host-functions/ (accessed on 16 October 2023).
- Wasmbus (Stable ABI)|WasmCloud. Available online: https://wasmcloud.com/docs/category/wasm-abis (accessed on 16 October 2023).
- Kanev, S.; Darago, J.P.; Hazelwood, K.; Ranganathan, P.; Moseley, T.; Wei, G.Y.; Brooks, D. Profiling a warehouse-scale computer. In Proceedings of the 42nd Annual International Symposium on Computer Architecture, Portland, OR, USA, 13–17 June 2015; ACM: New York, NY, USA, 2015; pp. 158–169. [Google Scholar] [CrossRef]
- Raghavan, D.; Levis, P.; Zaharia, M.; Zhang, I. Breakfast of Champions: Towards Zero-Copy Serialization with NIC Scatter-Gather. In Proceedings of the Workshop on Hot Topics in Operating Systems, Providence, RI, USA, 22–24 June 2023; pp. 199–205. [Google Scholar] [CrossRef]
- Sriraman, A.; Dhanotia, A. Accelerometer: Understanding acceleration opportunities for data center overheads at Hyperscale. In Proceedings of the International Conference on Architectural Support for Programming Languages and Operating Systems—ASPLOS, Lausanne, Switzerland, 16–20 March 2020; pp. 733–750. [Google Scholar] [CrossRef]
- Google. Tutorials|Protocol Buffers Documentation. Available online: https://protobuf.dev/getting-started/ (accessed on 22 January 2023).
- Furuhashi, S. MessagePack: It’s like JSON. But Fast and Small. Available online: https://msgpack.org/ (accessed on 22 January 2023).
- Google. FlatBuffers: Use in Rust. Available online: https://flatbuffers.dev/flatbuffers_guide_use_rust.html (accessed on 22 January 2023).
- Google. FlatBuffers: Platform/Language/Feature Support. Available online: https://flatbuffers.dev/flatbuffers_support.html (accessed on 22 January 2023).
- Cap’n Proto: Encoding Spec. Available online: https://capnproto.org/encoding.html#security-considerations (accessed on 22 January 2023).
- OSCON 2010: Rob Pike, ‘Public Static Void’—YouTube. Available online: https://www.youtube.com/watch?v=5kj5ApnhPAE (accessed on 17 December 2023).
- Llopis, N. Data-Oriented Design (Or Why You Might Be Shooting Yourself in the Foot with OOP)—Games from within. Available online: https://gamesfromwithin.com/data-oriented-design (accessed on 24 November 2023).
- DICE. A Step Towards Data Orientation|PPT. Available online: https://pt.slideshare.net/DICEStudio/a-step-towards-data-orientation (accessed on 22 January 2024).
- Acton, M. CppCon 2014: Mike Acton ‘Data-Oriented Design and C++’—YouTube. Available online: https://www.youtube.com/watch?v=rX0ItVEVjHc (accessed on 22 January 2024).
- DICE. Introduction to Data Oriented Design|PPT. Available online: https://pt.slideshare.net/DICEStudio/introduction-to-data-oriented-design (accessed on 22 January 2024).
- DOTS—Unity’s Data-Oriented Technology Stack. Available online: https://unity.com/dots (accessed on 26 November 2023).
- C# Language Support|Burst|1.8.11. Available online: https://docs.unity3d.com/Packages/[email protected]/manual/csharp-language-support.html (accessed on 26 November 2023).
- Odin Programming Language. Available online: https://odin-lang.org/ (accessed on 11 November 2023).
- Jai Programming Language Resources and Information. Available online: https://inductive.no/jai/ (accessed on 26 November 2023).
- Home ⚡ Zig Programming Language. Available online: https://ziglang.org/ (accessed on 11 November 2023).
- Richard, F. Data-Oriented Design: Software Engineering for Limited Resources and Short Schedules, 1st ed.; Ingram International Inc.: La Vergne, TN, USA, 2018; Volume 1. [Google Scholar]
- Straume, P.-M. Investigating Data-Oriented Design. 2019. Available online: https://ntnuopen.ntnu.no/ntnu-xmlui/handle/11250/2677763 (accessed on 25 November 2023).
- Karlsson, M. Evaluation of Object-Space Occlusion Culling with Occluder Fusion. 2011. Available online: https://www.semanticscholar.org/paper/Evaluation-of-Object-Space-Occlusion-Culling-with-Karlsson/a8e7758df9f651e90e532863766861328b30c199 (accessed on 11 November 2023).
- Wells, A.M.; Prabha, A.M. Intel® HPC Developer Conference Fuel Your Insight Improve Vectorization Efficiency Using Intel Simd Data Layout Template (Intel Sdlt). 2016. Available online: https://www.intel.com/content/dam/www/public/us/en/documents/presentation/improving-vectorization-efficiency.pdf (accessed on 12 December 2023).
- Albrecht, T. Pitfalls of Object Oriented Programming; M & T Books: Buffalo, NY, USA, 2014. [Google Scholar]
- Homann, H.; Laenen, F. SoAx: A generic C++Structure of Arrays for handling particles in HPC codes. Comput. Phys. Commun. 2018, 224, 325–332. [Google Scholar] [CrossRef]
- Data Alignment to Assist Vectorization. Available online: https://www.intel.com/content/www/us/en/developer/articles/technical/data-alignment-to-assist-vectorization.html (accessed on 13 January 2024).
- Eberhardt, C. The State of WebAssembly 2023. Available online: https://blog.scottlogic.com/2023/10/18/the-state-of-webassembly-2023.html (accessed on 16 October 2023).
- Assume_no_Moving_gc Package—Go4.org/unsafe/assume-no-moving-gc—Go Packages. Available online: https://pkg.go.dev/go4.org/unsafe/assume-no-moving-gc#section-readme (accessed on 17 January 2024).
- A08 Software and Data Integrity Failures—OWASP Top 10:2021. Available online: https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/ (accessed on 25 November 2023).
- Deserialization of Untrusted Data|OWASP Foundation. Available online: https://owasp.org/www-community/vulnerabilities/Deserialization_of_untrusted_data (accessed on 25 November 2023).
- Krill, P. Oracle Plans to Dump Risky Java Serialization|InfoWorld. Available online: https://news.ycombinator.com/item?id=17165800 (accessed on 25 November 2023).
- HTML Standard. Available online: https://html.spec.whatwg.org/multipage/webstorage.html#sensitivity-of-data (accessed on 23 November 2023).
- RabbitMQ tutorial—Routing—RabbitMQ. Available online: https://www.rabbitmq.com/tutorials/tutorial-four-spring-amqp.html (accessed on 31 January 2024).
- Pankaj. Gangs of Four (GoF) Design Patterns|DigitalOcean. Available online: https://www.digitalocean.com/community/tutorials/gangs-of-four-gof-design-patterns (accessed on 31 January 2024).
- Design Patterns in Dynamic Programming. Available online: https://kidneybone.com/c2/wiki/DesignPatternsInDynamicProgramming (accessed on 31 January 2024).
- Are Design Patterns Missing Language Features. Available online: https://kidneybone.com/c2/wiki/AreDesignPatternsMissingLanguageFeatures (accessed on 31 January 2024).
- Amazon. Restrictions on Lambda@Edge—Amazon CloudFront. Available online: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-at-edge-function-restrictions.html (accessed on 31 January 2024).
- Netlify. Functions Overview|Netlify Docs. Available online: https://docs.netlify.com/functions/overview/ (accessed on 31 January 2024).
- Vercel. Edge Functions Limitations. Available online: https://vercel.com/docs/functions/edge-functions/limitations (accessed on 31 January 2024).
- Surma. Bringing Javascript to WebAssembly for Shopify Functions. 2024. Available online: https://shopify.engineering/javascript-in-webassembly-for-shopify-functions (accessed on 31 January 2024).
- Server Operating System Market Volume, Share|Analysis, 2030. Available online: https://www.fortunebusinessinsights.com/server-operating-system-market-106601 (accessed on 29 October 2023).
- Nyberg, F. Investigating the Effect of Implementing Data-Oriented Design Principles on Performance and Cache Utilization, UMEÅ University. 2021. Available online: https://www.diva-portal.org/smash/get/diva2:1578616/FULLTEXT01.pdf (accessed on 29 October 2023).
- Mytkowicz, T.; Diwan, A.; Hauswirth, M.; Sweeney, P.F. Producing Wrong Data without Doing Anything Obviously Wrong! ACM Sigplan Not. 2009, 44, 265–276. [Google Scholar] [CrossRef]
- Série B expansível—Máquinas Virtuais do Azure—Azure Virtual Machines|Microsoft Learn. Available online: https://learn.microsoft.com/pt-pt/azure/virtual-machines/sizes-b-series-burstable (accessed on 26 January 2024).
- Test Package—Cmd/go/internal/test—Go Packages. Available online: https://pkg.go.dev/cmd/go/internal/test (accessed on 24 January 2024).
- Benchstat Command—Golang.org/x/perf/cmd/benchstat—Go Packages. Available online: https://pkg.go.dev/golang.org/x/perf/cmd/benchstat (accessed on 26 January 2024).
- Cap’n Proto: Introduction. Available online: https://capnproto.org/ (accessed on 31 January 2024).
- Neward, T. The Vietnam of Computer Science. 2006. Available online: https://www.odbms.org/wp-content/uploads/2013/11/031.01-Neward-The-Vietnam-of-Computer-Science-June-2006.pdf (accessed on 8 November 2023).
Feature | JSON | MessagePack | ProtoBuf | FlatBuffers | Cap’n’Proto | Karmem |
---|---|---|---|---|---|---|
Requires schema description | No | No | Yes | Yes | Yes | Yes |
Schema evolution | N/A | N/A | Yes | Yes | Yes | Yes |
Compression | None | Low | High | Low | None | None |
Supports random access | No | No | No | Yes | Yes | Yes |
Security | High | High | High | Low | High | Medium |
Languages coverage | High | High | High | Medium | Medium | Low |
Generator integration | N/A | N/A | External | Built-In | External | Built-In |
Reference implementation | JS | C | C++ | C++ | C++ | Go and Zig |
Maximum Size | N/A | N/A | N/A | 2 GB | 16 EB | 4 GB |
Supports custom default value | N/A | N/A | Yes | Yes | Yes | No |
Supports fixed-size vector | N/A | N/A | Yes | Yes | No | Yes |
Supports vector of vectors | N/A | N/A | No | No | Yes | No |
Supports map/dictionary | N/A | N/A | Yes | No | No | No |
Configurations | PC1 | PC2 | PC3 | PC4 | PC5 |
---|---|---|---|---|---|
Operating System | FreeBSD 13.2 | Ubuntu 22.04.3 | Debian 10 | macOS 14.0 | Ubuntu 22.04.3 |
Virtualization | Proxmox (7.3-6) | None | None | Azure (B1s) | |
RAM size | 8192 MB | 65,536 MB | 32,768 MB | 1024 MB | |
RAM type | DDR4 | DDR4 | LPDDR5 | - 1 | |
ECC | Multi-bit | Multi-bit | - 2 | - 2 | |
RAM Bandwidth | 2400 MT/s | 3200 MT/s | 6400 MT/s | - 2 | |
CPU | AMD EPYC 7551P (2017) | AMD Ryzen 7 3700X (2019) | Apple M2 Max (2023) | Intel Xeon Platinum 8272CL (2019) | |
Threads number | 4 3 | 16 | 12 | 14 4 | |
CPU clock speed | 2000.00 MHz | 2194.70 MHz | 2424.00 MHz | 2600.00 MHz | |
Cache size | L1: 96 KB L2: 512 KB L3: 64 MB 4 | L1: 512 KB L2: 4 MB L3: 32 MB 5 | L1: 192 KB L2: 32 MB 5 L3: 48 MB 5 | L1: 64 KB L2: 1 MB L3: 36 MB 5 | |
Cache line size | 64 bytes | 64 bytes | 128 bytes | 64 bytes | |
TLB size | 2560 4KB Page | 3072 4KB Page | 2048 16KB Page | 1536 4KB Page |
Fixed | Stride | Fixed+SIMD | SoA | SoA+SIMD | AoP | |
---|---|---|---|---|---|---|
PC1 | +76.15% | +107.95% | ~ | −56.75% | −74.72% | +37.87% |
PC2 | +74.87% | +102.09% | ~ | −56.82% | −74.27% | +39.30% |
PC3 | +111.19% | +117.58% | +18.29% | −53.72% | −73.37% | +51.22% |
PC4 | +46.64% | +51.03% | −26.91% | −63.39% | −73.19% | +27.84% |
PC5 | +71.30% | +84.86% | −9.02% | −59.26% | −73.94% | +40.39% |
M | +74.85% | +91.17% | +9.72% | −58.12% | −73.91% | +39.12% |
Native | Fixed | Stride | Fixed+SIMD | SoA | SoA+SIMD | AoP | |
---|---|---|---|---|---|---|---|
PC1 | ±1% | ±2% | ±14% | ±38% | ±1% | ±1% | ±1% |
PC2 | ±1% | ±1% | ±11% | ±36% | ±1% | ±2% | ±0% |
PC3 | ±0% | ±3% | ±4% | ±9% | ±6% | ±1% | ±1% |
PC4 | ±1% | ±1% | ±1% | ±0% | ±1% | ±1% | ±0% |
PC5 | ±1% | ±1% | ±0% | ±1% | ±1% | ±1% | ±1% |
Size | Karmem | FlatBuffers | JSON |
---|---|---|---|
10 | 194.9 ns | 1215.5 ns | 5383.0 ns |
10,000 | 77.19 µs | 928.70 µs | 4308.86 µs |
Size | Karmem | FlatBuffers | JSON |
---|---|---|---|
10 | 316.4 ns | 5787.0 ns | - |
10,000 | 68.15 µs | 1325.57 µs | - |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Silva, L.; Metrôlho, J.; Ribeiro, F. Efficient Data Exchange between WebAssembly Modules. Future Internet 2024, 16, 341. https://doi.org/10.3390/fi16090341
Silva L, Metrôlho J, Ribeiro F. Efficient Data Exchange between WebAssembly Modules. Future Internet. 2024; 16(9):341. https://doi.org/10.3390/fi16090341
Chicago/Turabian StyleSilva, Lucas, José Metrôlho, and Fernando Ribeiro. 2024. "Efficient Data Exchange between WebAssembly Modules" Future Internet 16, no. 9: 341. https://doi.org/10.3390/fi16090341
APA StyleSilva, L., Metrôlho, J., & Ribeiro, F. (2024). Efficient Data Exchange between WebAssembly Modules. Future Internet, 16(9), 341. https://doi.org/10.3390/fi16090341