Performance Tips¶
Performance inside WASM scripting heavily depends on minimizing interop between Unity and the WASM VM.
-
Unity & Game APIs are evil.
- Any interaction with Unity or CVR is an external call and should be minimized where possible.
-
Keep interop low.
- Each call between the VM and Unity goes through multiple layers:
VM -> CVR Links -> Unity -> CVR Links -> VM-# The fewer roundtrips, the faster your code will run.
- Each call between the VM and Unity goes through multiple layers:
-
Cache frequently used data.
- Fetch objects or properties once and reuse them instead of repeatedly accessing Unity APIs or game wrappers.
... basically just dont spam game and unity apis, cache shit, and you're fine (this does not apply to just wasm) https://github.com/m7rk/vrchat-gameboy/issues/1
Example:¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |