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
JsValue::from_serde is very slow compare to pass string from WASM to js and then using JSON.parse to parse data.
Additional Details
I tried to use 'wasm-bindgen' to test performance of a general senario: request data from server at WASM and then pass data to JS, and find that the JsValue::from_serde is very slow.
And then I change to just pass response text to JS instead, and then using JSON.parse to parse text to json data, which compare to 'from_serde' is way better performance.
So I wanna ask if there's anything I can do to improve from_serde perfroamce?
The perfomrance profile (need to remove extra extension 'txt')
It generally depends on where the time is being spent. If the time is being spent copying the data into wasm's linear memory, that's unfortunately pretty difficult. If the time is spent in JSON parsing itself then you could consider parsing in JS and then passing pieces to wasm so you don't copy all of the data. Unfortunately though I don't have time myself to dig into this and provide more help at this time.
Summary
JsValue::from_serde is very slow compare to pass string from WASM to js and then using JSON.parse to parse data.
Additional Details
I tried to use 'wasm-bindgen' to test performance of a general senario: request data from server at WASM and then pass data to JS, and find that the
JsValue::from_serde
is very slow.And then I change to just pass response text to JS instead, and then using
JSON.parse
to parse text to json data, which compare to 'from_serde' is way better performance.So I wanna ask if there's anything I can do to improve
from_serde
perfroamce?The perfomrance profile (need to remove extra extension 'txt')
Profile-from_serde_vs_json_parse.json.txt
The performance screenshot
And the demo repo to reproduce this issue: https://github.com/maple-leaf/rust-wasm-playgroud
The text was updated successfully, but these errors were encountered: