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
Current implementation of the vector tile data transfer from web workers to the main thread is somewhat convoluted:
Convert TesselatedRenderBundle into TessellatedRenderBundleBytes, which is quite cheap conversion of all vertex vectors into byte vectors using bytemuck.
Serialize that structure into byte vector using bincode.
Convert that into JsValue with serde_wasm_bindgen.
And then go in reverse order in the main thread to decode it all. Step 2 and probably step 3 requires all data to be copied, which means that we do 4 copies in total - 2 in the worker and 2 in the main thread. Even such, this is much faster then doing serde_wasm_bindgen deserialization directly for bincode deserialization is much faster.
There are a couple things to consider for optimization:
This comment by one of wasm-bindgen authors suggests, that we can transfer vectors with unsafe code by transferring a pointer, len and capacity (and mem::forgetting the original one). This seems logical, but this method documentation suggests that memory can be changed somehow when allocating anything. This needs investigation, what is true and what is not.
We do MVT tile decoding two times: in the worker and in the main thread. Maybe we can do it only one time...
The text was updated successfully, but these errors were encountered:
Current implementation of the vector tile data transfer from web workers to the main thread is somewhat convoluted:
serde_wasm_bindgen
.And then go in reverse order in the main thread to decode it all. Step 2 and probably step 3 requires all data to be copied, which means that we do 4 copies in total - 2 in the worker and 2 in the main thread. Even such, this is much faster then doing
serde_wasm_bindgen
deserialization directly for bincode deserialization is much faster.There are a couple things to consider for optimization:
wasm-bindgen
authors suggests, that we can transfer vectors with unsafe code by transferring a pointer, len and capacity (and mem::forgetting the original one). This seems logical, but this method documentation suggests that memory can be changed somehow when allocating anything. This needs investigation, what is true and what is not.The text was updated successfully, but these errors were encountered: