# Efficient Data Exchange between WebAssembly Modules
## 1 Introduction  
For years, web development was almost exclusively in JavaScript (JS). Although various technologies such as Microsoft Silverlight, Java Applets, and Google Native Client (NaCL) have been used to support other languages in the browser, these solutions have never been universally adopted natively by all browsers. WebAssembly (WASM) has recently emerged as a complementary solution to JS. It is a new bytecode with instructions closely resembling those of a conventional processor, but it runs in a sandbox, which limits access to memory and communication with the external world; this makes it secure and fast. The instructions are like those found in most processor architectures, somewhat akin to the Dis Virtual Machine used in InfernoOS [1]. WASM was designed to be general-purpose and usable in any language, although it initially emphasizes C/C++. This concept differs from other bytecodes, such as the Java Virtual Machine (JVM), which was originally developed for just one language, Java, and may have limitations when used to express programs in other languages [2]. Due to the security and portability features of WASM, and its growing adoption as a compilation target by various languages, the technology has been used in other scenariosbeyond the browser context. Currently, it can be found in cloud computing [3], edge computing [4], embedded devices [5], and blockchain [6]. However, with these new possibilities, new challenges have also emerged. The issue of efficient data communication between WASM modules has become a clear obstacle. Transferring data, such as text or vectors, between different modules is not a trivial task for many programmers [7], and the binary format of WASM 1.0 does not provide native features for transferring more complex data structures. In some applications, this can imply serious performance issues when communicating with the module's external environment [8]. The specification of this technology, with its \"share-nothing\" nature, requires frequent copying to the memory of each of the modules [9]. This need for copying and data transformations has been observed as a problem in some applications, such as Proxy-WASM [10]. The requirement to copy for each individual module can be particularly exacerbated in computational architectures with a \"one-to-many\" (fanout) pattern, or when large volumes of data need to be transferred to multiple distinct modules. Karmem aims to overcome the limitations of WASM by disregarding the share-nothing concept [11] and enabling more efficient communication. Its goal is to facilitate improved communication between WebAssembly modules through the implementation of a new interface description language (IDL) and its own communication protocol. Therefore, Karmem makes a meaningful contribution to the realm of WASM development by providing solutions for effective data communication among modules written in different languages. This holds practical significance for distributed applications built on WASM, thereby enhancing efficiency and interoperability. In addition to the research objective, motivation, and identification of the main contributions presented in this section, this article consists of five further sections. Section 2 provides a theoretical contextualization of WASM. Then, Section 3 summarizes the current state of alternative solutions and their goals, such as Karmem, in the context of communication in WASM. Section 4 elaborates on the goals and priorities of the Karmem approach. It introduces the features of the IDL designed to describe types, data structures, functions, and shared memory regions. The section also outlines the communication protocol specification and introduces a multifunctional development tool employed for code generation in various languages. Section 5 describes the tests conducted using Karmem to assess its ability to address challenges related to efficiency and interoperability in data communication between modules written in different languages.