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
The tldr is you can avoid the static_str_to_js cache by instead codegenning a JS function per struct that you serialize, which would likely also better this JS VM object construction caches. Some sample code from my prototype sketch. I'm not certain it's possible within the serde architecture -- serde is still a bit overwhelming to me -- but I think maybe it's a small tweak on ObjectSerializer?
In any case, I figured since you were interested in the performance of this area you might be interested in this. Feel free to close this bug if it doesn't suit you, I just figured this was the place to bring it to your attention.
The text was updated successfully, but these errors were encountered:
Yeah that would be ideal approach, but it's not possible / compatible with Serde, as it describes all structs at runtime.
The closest you can get is dynamically constructing and caching JS functions via js_sys::Function, but that's its own can of worms and not compatible with all environments.
Ideally static conversion like this should be implemented in wasm-bindgen itself or a separate proc-macro.
Thanks for making this crate!
I looked into its implementation a bit and have a possible improvement that I discuss here:
https://neugierig.org/software/blog/2024/04/rust-wasm-to-js.html
The tldr is you can avoid the
static_str_to_js
cache by instead codegenning a JS function per struct that you serialize, which would likely also better this JS VM object construction caches. Some sample code from my prototype sketch. I'm not certain it's possible within the serde architecture -- serde is still a bit overwhelming to me -- but I think maybe it's a small tweak onObjectSerializer
?In any case, I figured since you were interested in the performance of this area you might be interested in this. Feel free to close this bug if it doesn't suit you, I just figured this was the place to bring it to your attention.
The text was updated successfully, but these errors were encountered: