DEV Community

Discussion on: Reduce overhead for data serialization between Wasm & JS (Help!)

Collapse
 
shekohex profile image
shekohex

something I noticed when I opened the repo, here github.com/WenheLI/wasm-gif/blob/6...

you are doing an allocation (calling .to_vec()) which is not necessary here since you iterate over it again so why you make a separate copy of every frame on that hot loop?

Collapse
 
wenheli profile image
WenheLI

yep, that's definitely a redundant allocation!
However, based on the performance I measured, I found the major overhead exists in JsValue::from_serde(&gif).unwrap() where this process took up to 90% execution time of the whole function.
Thanks anyway!
BTW, I am wondering if there is a way to pass an object reference to wasm runtime or can wasm return a stream object?