You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, amazing library, I am using the web export and this has increased development speed tremendously, thank you for your work.
I am curious on thoughts/best practices around native type marshalling - I've noticed in debug output that in cases where native types are created on the stack and returned they will trigger the gc.alloc debug command, example is in Vector3 methods:
Will result in an allocation. I have been implementing TS extensions to allow for mutating the same object with the same logic for many of these utility functions like add, scale, etc. and keeping static instances for utilities. Also for getters on a node3d like node.global_position.x the global_position will allocate a Vector3 which seems like an expensive operation. Same with _input events for mouse/keyboard - they will be wrapped and allocated.
Do you think this is something that doesn't require optimization? I am trying to be as strict as possible in WASM environment, creating a wrapper for marshalling simple types without copies. Was curious your thoughts on this approach?
Of course, resuing the wrapped value is a good practice to improve critical performance.
However, eval_plain introduces string marshaling, hashing, more function calls, and cross-domain invocations, which is slower than a simple Vector3 wrapper instance allocation in most situations.
The only way to avoid extra allocations is to use bridge calls implemented in C++,
The valuetype binding for web.imp (using the host JS) is not performant enough in the current version.
I'll try solutions to improve it.
Such as using HEAP32F[get_internal_address_of(vec2)] to get the component of a Vector2 in xxx = vec2.x
Great, I will look and see what might make sense with extensions on the C++ side. I've already made proto extensions for Vector math on the JS/TS side which mutate rather than copy.. Sort of changes the behavior but it works. The godot <-> js binding is unfortunate and I am trying to keep memory overhead down vs cpu at the moment since that's a weak point in wasm, when I see "allocation" i try to bury it.
I'd be happy to help take a look where I notice things stick out and when I'm doing a bigger optimization, I've only started diving into the web impl code. Maybe overloading for Vector methods with Float32Array or float args with embind... I noticed the FinalizationRegistry callbacks tend to get called parallel to the GC pass in the browser and can cause a big hiccup. Splitting those into requestIdleCallback would help not do all the work in one frame.
Hello, amazing library, I am using the web export and this has increased development speed tremendously, thank you for your work.
I am curious on thoughts/best practices around native type marshalling - I've noticed in debug output that in cases where native types are created on the stack and returned they will trigger the gc.alloc debug command, example is in Vector3 methods:
Will result in an allocation. I have been implementing TS extensions to allow for mutating the same object with the same logic for many of these utility functions like
add
,scale
, etc. and keeping static instances for utilities. Also for getters on a node3d likenode.global_position.x
the global_position will allocate a Vector3 which seems like an expensive operation. Same with _input events for mouse/keyboard - they will be wrapped and allocated.Do you think this is something that doesn't require optimization? I am trying to be as strict as possible in WASM environment, creating a wrapper for marshalling simple types without copies. Was curious your thoughts on this approach?
and GDBridge:
The text was updated successfully, but these errors were encountered: