# Efficient Data Exchange between WebAssembly Modules
## 5 Results and Discussion
### Performance Analysis
#### 5.1.2 Dynamic Structures Test  
This test aims to validate the tests previously conducted in another article [65], as well as to validate the hypothesis that DOD could be even better considering dynamic structures, which will be used in Karmem. The test consists of the structure demonstrated in Figure 20. Within it, there are three data structures, in AoS, SoA, and AoP, used in the variables \"scooters_aos\", \"scooters_soa\", and \"scooters_aop\". Additionally, there is \"scooters_aos_u32\", which uses AoS as a vector of u32. This vector points to the same location as \"scooters_aos\". The structure is exactly 64 bits (8 bytes) to allow for SIMD use, as WASM only supports 128 bits, although this may be subject to change in the future. The function to be executed is demonstrated in Figure 20, where all fields of \"distance\" are updated by a single variable at runtime. The host is responsible for providing the values, and the guest exports the functions, which always receive an input value. Since there are tests in shared environments (PC1, PC2, and PCS), all tests were executed in random order and repeatedly. All tests were performed 64 times, except for the native test, which was executed 65 times. Different variations were created to achieve the goal of adding value to all distances. These different implementations allow for an analysis of the impact of data organization and the possible optimizations performed automatically by the compiler, which may not be applicable to non-native (or non-fixed) structures. The implementations are explained below. Native: The native test aims to test the performance of the language's native structure in AoS format. Its implementation is as natural as possible, as can be seen in Figure 21. This code iterates through each scooter and increments its velocity without any explicit optimization. This code is automatically vectorized by the compiler, which will utilize SIMD when possible. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Configurations** & **PC1** & **PC2** & **PC3** & **PC4** & **PC5** \\ \hline Operating System & FreeBSD 13.2 & Ubuntu 22.04.3 & Debian 10 & macOS 14.0 & Ubuntu 22.04.3 \\ \hline 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 \\ AMD & AMD & Apple & Intel Xeon \\ CPU & EPYC 7551P & Ryzen 7 3700X & M2 Max & Platinum 8272 CL \\  & (2017) & (2019) & (2023) & (2019) \\ Threads number & 4 3  & 16 & 12 & 14  \\  & 2000.00 & 2194.70 & 2424.00 & 2600.00 \\ CPU clock speed & MHz & MHz & MHz & MHz \\  & L1: 96 KB & L1: 512 KB & L1: 192 KB & L1: 64 KB \\ Cache size & L2: 512 KB & L2: 4 MB & L2: 32 MB 5  & L3: 64 MB 6  & L3: 64 MB 6  & L3: 36 MB 6  \\ Cache line size & 64 bytes & 64 bytes & 128 bytes & 64 bytes \\ TLB size & 2560 4 KB Page & 3072 4 KB Page & 2048 16 KB Page & 1536 4 KB Page \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Hardware configurations of the devices used for testing. ```
1.constScooterAoS=struct{
2.id:u32=0,
3.distance:u32-0,
4. };
5. 6.constScooterSoA=struct{
7.ids:[]u32=undefined,
8.distances:[]u32=undefined,
9. };
10. 11.varscooters_aos:[]ScooterAoS=undefined;
12. 13.varscooters_soa:ScooterSoA=ScooterSoA{};
14. 15.varscooters_aos_u32:[]u32=undefined;
16. 17.varscooters_aop:[]*ScooterAoS=undefined;
18. 19.varscooters_aop_u32:[]u32=undefined;
20. 21.varscooters_count:u32=0;
22. 23.varscooters_runtime_stride:u32=0;
```  
Figure 21: Code implementing the native test, in Zig. Figure 22: Code implementing the fixed test, in Zig. Fixed+SIMD: This has an implementation identical to fixed but uses the manual vectorization feature of the Zig programming language. This allows for SIMD usage, consequently adding two elements at a time, which are the second and fourth elements of a lane of 4 xu32. Figure 24 represents the implementation of this test. Since the size is fixed, we know that the second number is the distance.